SoFunction
Updated on 2025-04-14

7 JavaScript Differences between FF and IE


5. Get the cursor position
It is rare to get the cursor position of an element. If you need to do this, the syntax of IE and Firefox is also different. This sample code is quite basic and is generally used as part of many complex event processing, and is only used to describe the differences here. It should be noted that the results in IE are different from those in Firefox, so this method has some problems. Usually, this difference can be compensated by getting the "scroll position" - but that's the subject of another article.

IE syntax:
Copy the codeThe code is as follows:

var myCursorPosition = [0, 0];
myCursorPosition[0] = ;
myCursorPosition[1] = ;

Firefox syntax:
Copy the codeThe code is as follows:

var myCursorPosition = [0, 0];
myCursorPosition[0] = ;
myCursorPosition[1] = ;

6. Get the size of the window or browser window
Sometimes it is necessary to find out the size of the effective window space of the browser, which is usually a "window".

IE syntax:
Copy the codeThe code is as follows:

var myBrowserSize = [0, 0];
myBrowserSize[0] = ;
myBrowserSize[1] = ;

Firefox syntax:
Copy the codeThe code is as follows:

var myBrowserSize = [0, 0];
myBrowserSize[0] = ;
myBrowserSize[1] = ;

7. Alpha transparent
Well, this is not actually a syntax project for JavaScript - alpha transparency is set through CSS. However, when the object is set to fade in and out through JavaScript, this needs to be achieved by obtaining the alpha settings of the CSS, which is generally inside the loop. To change the CSS code with the following javascript:

IE syntax:
Copy the codeThe code is as follows:

#myElement {
filter: alpha(opacity=50);
}

Firefox syntax:
Copy the codeThe code is as follows:

#myElement {
opacity: 0.5;
}

To get these values ​​using JavaScript, you need to use a style object:

IE syntax:
Copy the codeThe code is as follows:

var myObject = ("myElement");
= "alpha(opacity=80)";

Firefox syntax:
Copy the codeThe code is as follows:

var myObject = ("myElement");
= "0.5";

Of course, it has been mentioned that it is generally to change opcity/alpha in the middle of a loop to create animation effects, but this is a simple example, just to clearly describe how the method is implemented.

Original text: /7-javascript-differences-between-firefox-ie
Translation:/