search
HomeWeb Front-endJS TutorialSummary of JS IE and FF compatibility issues_javascript skills

1. document.form.item problem
Existing problem:
There are many statements like document.formName.item("itemName") in the existing code, which cannot be run under MF
Solution:
Use document.formName.elements["elementName"] instead
Others
See 2
2. Collection class object issues
Existing issues :
Many collection class objects in the existing code use () when accessing them. IE can accept it, but MF cannot.
Solution:
Use [] instead as subscript operation. For example: document.forms("formName") is changed to document.forms["formName"].
Another example: document.getElementsByName("inputName")(1) changed to document.getElementsByName("inputName")[1]
3. window.event
Existing issues :
Using window.event cannot be run on MF
Solution:
MF's event can only be used at the scene where the event occurs, and this problem cannot be solved yet. It can be modified like this:
Original code (can run in IE):

...


New code (can run in IE and MF):

...

In addition, if the first line of the new code does not change and is the same as the old code (that is, the gotoSubmit call does not give parameters), it will still only Can run in IE, but no errors. Therefore, the tpl part of this solution is still compatible with the old code.
4. The problem of using the id of an HTML object as an object name

Existing problems:
In IE, the ID of an HTML object can be used directly as the variable name of a subordinate object of document. Not in MF.
Solution: Use getElementById("idName") instead of idName as an object variable.
5. Problems with using idName string to obtain objects

Existing problems:
In IE, you can use eval(idName) to obtain the HTML object with the id of idName. In MF cannot.
Solution: Use getElementById(idName) instead of eval(idName).
6. The problem that the variable name is the same as an HTML object id

Existing problems:
In MF, because the object id is not used as the name of the HTML object, it can be used with HTML Variable names with the same object id cannot be used in IE.
Solution:
When declaring variables, always add var to avoid ambiguity, so that they can run normally in IE.
In addition, it is best not to take the same variable name as the HTML object id to reduce errors.
Others: See question 4
7. Event.x and event.y issues

Existing issues:
In IE, the event object has x, y Attribute, not available in MF.
Solution:
In MF, the equivalent of event.x is event.pageX. But event.pageX is not available in IE.
So event.clientX is used instead of event.x. This variable also exists in IE.
Event.clientX and event.pageX have subtle differences (when the entire page has scroll bars), but most of the time they are equivalent.
If you want to be exactly the same, you can have a little more trouble:
mX = event.x ? event.x : event.pageX;
Then use mX instead of event.x
Others: event. layerX is available in both IE and MF. Whether there is any specific difference has not yet been tested.
8. About frame

Existing problems:
You can use window.testFrame to get the frame in IE, but not in mf
Solution:
In frame The main difference between mf and ie in terms of usage is: If the following attributes are written in the frame tag:


Then ie can access the window object corresponding to this frame through id or name
And 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 inside the top window, then you can access it like this
ie: window.top.frameId or window .top.frameName to access this window object
mf: Only window.top.frameName can be used to access this window object
In addition, window.top.document.getElementById("frameId" can be used in both mf and ie ") to access the frame tag
and you can use window.top.document.getElementById("testFrame").src = 'xx.htm' to switch the content of the frame
or you can use window.top.frameName. location = 'xx.htm' to switch the content of the frame
For a description of frame and window, please refer to the 'window and frame' article of bbs
and the test under the /test/js/test_frame/ directory - ---adun 2004.12.09 Modification
9. In mf, the attributes you define must be obtained by getAttribute()

10. There is no parentElement parement.children in mf but use parentNode parentNode. childNodes
The meaning of the subscript of childNodes is different in IE and MF. MF uses DOM specification, and blank text nodes will be inserted into childNodes.
Generally, this problem can be avoided through node.getElementsByTagName().
When a node is missing in html, IE and MF interpret parentNode differently, for example




MF의 input.parentNode 값은 form인 반면, IE의 input.parentNode 값은 빈 노드입니다.
MF의 노드에는 RemoveNode 메서드를 사용해야 합니다. 다음 방법 node.parentNode.removeChild( node)
11.const 문제
기존 문제:
IE에서는 const 키워드를 사용할 수 없습니다. const constVar = 32; 이는 IE의 구문 오류입니다.
해결책:
const를 사용하지 말고 대신 var를 사용하세요.
12. Body 개체
브라우저에서 body 태그를 완전히 읽기 전에 MF의 본문이 존재하는 반면, IE는 본문을 완전히 읽은 후에 존재해야 합니다.
13 . URL을 js로 작성하고 직접 작성하지 마세요. 예를 들어 var url = 'xx.jsp?objectName=xx&objectEvent=xxx'
frm.action = url이면 다음과 같습니다. 그로 인해 url이 정상적으로 표시되지 않게 됩니다.
일반적으로 서버에서는 해당 매개변수를 찾을 수 없다는 오류를 보고하게 됩니다
물론, 그런 경우는 예외입니다. tpl에서는 tpl이 xml 사양을 준수하고 &를 &로 작성해야 하기 때문입니다.
일반 MF는
14에서 js &를 인식할 수 없습니다. nodeName 및 tagName 문제
기존 문제:
MF에서는 모든 노드에 nodeName 값이 있지만 textNode에는 tagName 값이 없습니다. IE에서는 nodeName
사용에 문제가 있는 것 같습니다. (구체적인 상황은 테스트해보진 않았지만 IE가 여러번 죽었습니다.)
해결 방법:
tagName을 사용하되 비어 있는지 감지해야 합니다.
15. 요소 속성
input.type 속성은 IE에서는 읽기 전용이지만 MF
16에서는 수정할 수 있습니다. .all[name ] 문제
기존 문제:
IE에서는 getElementsByName()이나 document.all[name]을 사용하여 div 요소를 얻을 수 없습니다(다른 요소가 있는지는 모르겠습니다). 얻을 수 없는 것).
17. DOM 데이터 섬 문제
기존 문제:
IE에서 태그는 특별한 의미를 가지며 XML DOM을 포함할 수 있고 HTML 구성 요소로 구현될 수 있습니다. 바인딩. MF에서 은 알 수 없는 태그일 뿐입니다. 또한 IE의 경우 는 실제로 이것이 ActiveX 개체임을 의미하지만 HTML 자체의 DOM 트리에 걸려 있습니다.
해결책:
IE의 데이터 바인딩 메커니즘은 JS로 시뮬레이션할 수 있지만 너무 번거롭기 때문에 데이터 바인딩 메커니즘을 사용하지 않는 것이 좋습니다. 이러한 종류의 시뮬레이션을 구현하는 라이브러리 MF에서는 알려진 HTML 태그와 XML 사양을 준수하는 기타 태그가 모두 통합 DOM 트리를 사용하여 처리됩니다. , 그러나 IE와의 작은 차이점은 IE에서는 이 DOM 문서인 반면 MF에서는 단지 DOM 노드라는 것입니다. 이 차이점은 일반적으로 문제가 되지 않습니다. 다소 임의적인 HTML 구문을 사용하므로 MF는 축약된 빈 태그를 인식할 수 없습니다. 예: xxxx , 여기서 는 약어이므로 MF를 인식할 수 없게 됩니다. 그러나 XHTML을 사용하면 그런 문제가 없을 수도 있습니다. 아직 시도하지 않았습니다. IE에서 HTML의 DOM 구조를 방해하는 문제와 관련하여 현재의 방법은 처리 후 HTML의 DOM에서 삭제하는 것입니다. .
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Python vs. JavaScript: A Comparative Analysis for DevelopersPython vs. JavaScript: A Comparative Analysis for DevelopersMay 09, 2025 am 12:22 AM

The main difference between Python and JavaScript is the type system and application scenarios. 1. Python uses dynamic types, suitable for scientific computing and data analysis. 2. JavaScript adopts weak types and is widely used in front-end and full-stack development. The two have their own advantages in asynchronous programming and performance optimization, and should be decided according to project requirements when choosing.

Python vs. JavaScript: Choosing the Right Tool for the JobPython vs. JavaScript: Choosing the Right Tool for the JobMay 08, 2025 am 12:10 AM

Whether to choose Python or JavaScript depends on the project type: 1) Choose Python for data science and automation tasks; 2) Choose JavaScript for front-end and full-stack development. Python is favored for its powerful library in data processing and automation, while JavaScript is indispensable for its advantages in web interaction and full-stack development.

Python and JavaScript: Understanding the Strengths of EachPython and JavaScript: Understanding the Strengths of EachMay 06, 2025 am 12:15 AM

Python and JavaScript each have their own advantages, and the choice depends on project needs and personal preferences. 1. Python is easy to learn, with concise syntax, suitable for data science and back-end development, but has a slow execution speed. 2. JavaScript is everywhere in front-end development and has strong asynchronous programming capabilities. Node.js makes it suitable for full-stack development, but the syntax may be complex and error-prone.

JavaScript's Core: Is It Built on C or C  ?JavaScript's Core: Is It Built on C or C ?May 05, 2025 am 12:07 AM

JavaScriptisnotbuiltonCorC ;it'saninterpretedlanguagethatrunsonenginesoftenwritteninC .1)JavaScriptwasdesignedasalightweight,interpretedlanguageforwebbrowsers.2)EnginesevolvedfromsimpleinterpreterstoJITcompilers,typicallyinC ,improvingperformance.

JavaScript Applications: From Front-End to Back-EndJavaScript Applications: From Front-End to Back-EndMay 04, 2025 am 12:12 AM

JavaScript can be used for front-end and back-end development. The front-end enhances the user experience through DOM operations, and the back-end handles server tasks through Node.js. 1. Front-end example: Change the content of the web page text. 2. Backend example: Create a Node.js server.

Python vs. JavaScript: Which Language Should You Learn?Python vs. JavaScript: Which Language Should You Learn?May 03, 2025 am 12:10 AM

Choosing Python or JavaScript should be based on career development, learning curve and ecosystem: 1) Career development: Python is suitable for data science and back-end development, while JavaScript is suitable for front-end and full-stack development. 2) Learning curve: Python syntax is concise and suitable for beginners; JavaScript syntax is flexible. 3) Ecosystem: Python has rich scientific computing libraries, and JavaScript has a powerful front-end framework.

JavaScript Frameworks: Powering Modern Web DevelopmentJavaScript Frameworks: Powering Modern Web DevelopmentMay 02, 2025 am 12:04 AM

The power of the JavaScript framework lies in simplifying development, improving user experience and application performance. When choosing a framework, consider: 1. Project size and complexity, 2. Team experience, 3. Ecosystem and community support.

The Relationship Between JavaScript, C  , and BrowsersThe Relationship Between JavaScript, C , and BrowsersMay 01, 2025 am 12:06 AM

Introduction I know you may find it strange, what exactly does JavaScript, C and browser have to do? They seem to be unrelated, but in fact, they play a very important role in modern web development. Today we will discuss the close connection between these three. Through this article, you will learn how JavaScript runs in the browser, the role of C in the browser engine, and how they work together to drive rendering and interaction of web pages. We all know the relationship between JavaScript and browser. JavaScript is the core language of front-end development. It runs directly in the browser, making web pages vivid and interesting. Have you ever wondered why JavaScr

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

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

Notepad++7.3.1

Easy-to-use and free code editor

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.