IE和FireFox(FF)中js和css的不同_javascript技巧
在IE和FireFox(FF)中js和css的不同
css:
1.
ul标签中FF中有个padding值,却没有margin值,而在IE中正好相反
解决办法:将ul的padding和margin都设为0(也可以不是0)如:padding:0;margin:0;list-style:none;
js:
1.
IE中innerText在FF中没有,使用textContent;
eg:
var obj=document.getElementById("_td");
var text;
if(obj.innerText) {
text=obj.innerText;
} else if(obj.textContent) {
text=obj.textContent;
}
2.
在Ajax中返回对象状态IE可以使用readystate但是在FF中必须为readyState,所以最好是都写成readyState
3.获取IE和FF中的键盘返回值,
function test(e) {
var keyc=GetKeyCode(e);
alert(keyc);
}
function GetKeyCode(e) {//取得不同浏览器下的键盘事件值
var keyc;
if(window.event) {//ie键盘事件
keyc=e.keyCode;
} else if (e.which) {//火狐
keyc=e.which;
}
return keyc;
}
4.为对象添加移除事件
var obj=document.getElementById("_tname');
添加事件:
if(obj.attachEvent) {
obj.attachEvent("onchange",function() {
otherfunction(params);//这里可以给其实方法传参,也可以直接调用其它方法
});
} else if(obj.addEventListener) {
obj.addEventListener("change",function() {
otherfunction(params);
},false);
}
移除事件:
obj.onclick=null;
/*下面的代码为什么不行,IE下输出obj.onclick竟然为anonymous,希望高手能帮忙解决
if(obj.detachEvent) {
obj.detachEvent("onchange",test);
} else if(obj.removeEventListener) {
obj.removeEventListener("change",test,false);
}*/
5.
IE中event.x和event.y
在FF中只有event.pageX,event.pageY
都有event.clientX和event.clientY属性
解决办法:
var x=e.x?e.x:e.pageX;//e为event对象传进来的参数
6.IE下 input.type属性为只读,但是MF下可以修改
7.在 IE 中,getElementsByName()、(document.all[name] (还未测试成功))均不能用来取得 div元素(是否还有其它不能取的元素还不知道)。
8.通过js来触发事件
9.IE下event对象有srcElement属性,Firefox下,event对象有target属性
var obj=e.srcElement?e.srcElement:e.target;//e为event对象传进来的参数
//从这里下面的还未测试
10.在FF中自己定义的属性必须getAttribute()取得
11.节点问题
IE中使用parentElement parement.children,而FF中使用parentNode parentNode.childNodes
childNodes的下标的含义在IE和FF中不同,FF使用DOM规范,childNodes中会插入空白文本节点。
FF中节点没有removeNode方法,必须使用如下方法 node.parentNode.removeChild(node)

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











To remove FirefoxSnap in Ubuntu Linux, you can follow these steps: Open a terminal and log in to your Ubuntu system as administrator. Run the following command to uninstall FirefoxSnap: sudosnapremovefirefox You will be prompted for your administrator password. Enter your password and press Enter to confirm. Wait for command execution to complete. Once completed, FirefoxSnap will be completely removed. Note that this will remove versions of Firefox installed via the Snap package manager. If you installed another version of Firefox through other means (such as the APT package manager), you will not be affected. Go through the above steps

It's no secret that Internet Explorer has fallen out of favor for a long time, but with the arrival of Windows 11, reality sets in. Rather than sometimes replacing IE in the future, Edge is now the default browser in Microsoft's latest operating system. For now, you can still enable Internet Explorer in Windows 11. However, IE11 (the latest version) already has an official retirement date, which is June 15, 2022, and the clock is ticking. With this in mind, you may have noticed that Internet Explorer sometimes opens Edge, and you may not like it. So why is this happening? exist

More and more users are starting to upgrade the win11 system. Since each user has different usage habits, many users are still using the ie11 browser. So what should I do if the win11 system cannot use the ie browser? Does windows11 still support ie11? Let’s take a look at the solution. Solution to the problem that win11 cannot use the ie11 browser 1. First, right-click the start menu and select "Command Prompt (Administrator)" to open it. 2. After opening, directly enter "Netshwinsockreset" and press Enter to confirm. 3. After confirmation, enter "netshadvfirewallreset&rdqu

Mozilla Firefox can be uninstalled; Firefox is a third-party browser and can be uninstalled if it is not needed. Uninstallation method: 1. In the Start menu, click "Windwos System" - "Control Panel"; 2. In the "Control Panel" interface, click "Programs and Features"; 3. In the new interface, find and double-click Firefox Browser icon; 4. In the uninstall pop-up window, click "Next"; 5. Click "Uninstall".

June 15, 2022 is the day when Microsoft ends support for Internet Explorer 11 (IE11) and closes its legacy browser chapter. The company has been reminding users of this end-of-life date for some time and calling on them to plan a move to Microsoft Edge. Microsoft bundles IE11 with Windows 8.1 as the modern default web browser for Windows. Although it never reached the (current) heights of Chrome, it was the second most used desktop browser in 2014, behind IE8. Of course, with 20

Recently, many win10 users have found that their IE browser always automatically jumps to the edge browser when using computer browsers. So how to turn off the automatic jump to edge when opening IE in win10? Let this site carefully introduce to users how to automatically jump to edge and close when opening IE in win10. 1. We log in to the edge browser, click... in the upper right corner, and look for the drop-down settings option. 2. After we enter the settings, click Default Browser in the left column. 3. Finally, in the compatibility, we check the box to not allow the website to be reloaded in IE mode and restart the IE browser.

How to enable IE acceleration function? IE is too slow to open web pages, we can enable hardware acceleration mode in it. Many friends reported that when using IE browser, the speed of opening web pages is extremely slow, which also has a certain impact on our browsing of the web. I just want to ask the editor if there is any solution. In this case, you can turn on the hardware acceleration mode of the IE browser. The editor has compiled the method of turning on the acceleration function of IE. If you are interested, take a look below! To enable the acceleration function in IE, open the IE secure browser, click the gear-shaped "Settings" icon in the upper right corner, and select "Internet Options" to enter, as shown in the figure. 2. Click "Advanced" in the tab navigation at the head of the Internet Options window, as shown in the figure. 3.

According to recent news, while Mozilla released the stable version of Firefox 112, it also announced that the next major version, Firefox 113, has entered the Beta channel and supports AV1 animations, enhanced password generator and picture-in-picture features. The main new functions/features of Firefox 113 are as follows: Support for AV1 format animated images (AVIS); Enhance the security of the password generator by introducing special characters; Enhance the picture-in-picture function, support rewind, display video time, and enable full screen more easily Mode provides official DEB installation files for Debian and Ubuntu distributions. Updated bookmark import feature, icons for imported bookmarks are supported by default. Hardware accelerated AV1 video decoding is enabled by default on supported hardware using w
