SoFunction
Updated on 2025-04-14

Analysis of Javascript multiple browser compatibility writing methods page 3/3


7. With the problem
(1) Existing problems
In IE, the event object has x, y attributes, but not in MF.
(2) Solution
In MF, the equivalent is . But not in IE.
Therefore, use instead. This variable is also available in IE.
There is a subtle difference from (when the entire page has scroll bars), but most of the time it is equivalent.

If you want to be exactly the same, you can be a little troublesome:
mX = ? : ;
Then use mX instead
(3) Others
It is available in IE and MF, and whether there is a difference in specific meanings has not been tested.


8. About frame
(1) Existing problems
In IE, you can use this frame, but not in mf
(2) Solution
The most important difference between mf and ie in the use of frame is:
If the following attributes are written in the frame tag:
<frame src="" name="frameName" />
Then ie can access the window object corresponding to this frame through id or name
mf can only access the window object corresponding to this frame through name
For example, if the above frame tag is written in the htm in the uppermost window, then you can access it like this
ie: Or visit this window object
mf: This is the only way to access this window object

In addition, both mf and ie can be used ("frameId") to access frame tags
And you can switch the content of the frame by ("testFrame").src = ''
You can also switch the content of the frame by = ''
For descriptions of frame and window, please refer to bbs' article 'window and frame'
And the test below the /test/js/test_frame/ directory
----adun 2004.12.09 Modified

9. In mf, the attributes defined by yourself must be obtained by getAttribute().
10. Use without parentElement in mf
parentNode
The meaning of childNodes subscript is different in IE and MF. MF uses the DOM specification, and blank text nodes are inserted in childNodes.
This problem can generally be avoided by ().
When nodes are missing in html, IE and MF interpret parentNode differently, e.g.
<form>
<table>
<input/>
</table>
</form>
The value in MF is form, while the value in IE is an empty node

Nodes in MF do not have a removeNode method, so the following method (node) must be used.

question
(1) Existing problems:
The const keyword cannot be used in IE. For example, const constVar = 32; in IE this is a syntax error.
(2) Solution:
Don't use const, use var instead.

12. Body object
The body of MF exists before the body tag is fully read in by the browser, while IE must exist after the body is fully read in.

13. url encoding
If you write url in js, just write it directly & don't write it&amp;For example, var url = '?objectName=xx&amp;objectEvent=xxx';
= url, then it is very likely that the url will not be displayed normally so that the parameters are not correctly passed to the server.
Generally, the server will report an error parameter but not found
Of course, if it is an exception in tpl, because tpl complies with the XML specifications, it is required to be written as &amp;
Generally, MF cannot recognize &amp in js;


14. NodeName and tagName issues
(1) Existing problems:
In MF, all nodes have nodeName values, but textNode does not have tagName values. In IE, nodeName is used as if it is used.
There is a problem (there is no test in the specific case, but my IE has died several times).
(2) Solution:
Use tagName, but it should be detected if it is empty.

15. Element properties
Under IE, the attribute is read-only, but can be modified under MF.


16. Issues with () and [name]
(1) Existing problems:
In IE, getElementsByName() and [name] cannot be used to obtain div elements (it is not known whether there are other elements that cannot be taken).
Previous page123Read the full text