Problem description: Under IE, you can use document.formName.item("itemName") or document.formName.elements ["elementName"]; under Firefox, you can only use document.formName.elements["elementName"]. Solution: Use document.formName.elements["elementName"] uniformly.
2. Problems with collection objects
Problem description: Under IE, you can use () or [] to obtain collection objects; under Firefox, you can only use [ ] Get the collection class object. Solution: Use [] uniformly to obtain collection objects.
3. Custom attribute problem
Problem description: Under IE, you can use the method of getting regular attributes to get custom attributes, or you can use getAttribute() to get them Custom attributes; under Firefox, you can only use getAttribute() to obtain custom attributes. Solution: Get custom attributes through getAttribute().
4. eval("idName") problem
Problem description: Under IE, you can use eval("idName") or getElementById("idName") to obtain The HTML object whose id is idName; under Firefox, you can only use getElementById("idName") to obtain the HTML object whose id is idName. Solution: Use getElementById("idName") uniformly to obtain the HTML object with the id of idName.
5. The problem that the variable name is the same as the ID of an HTML object
Problem description: Under IE, the ID of the HTML object can be used directly as the variable name of the subordinate object of the document. , but not under Firefox; under Firefox, you can use the same variable name as the HTML object ID, but not under IE. Workaround: Use document.getElementById("idName") instead of document.idName. It is best not to use variable names with the same HTML object ID to reduce errors; when declaring variables, always add the var keyword to avoid ambiguity.
6. Const problem
Problem description: Under Firefox, you can use the const keyword or the var keyword to define constants; under IE, you can only use the var keyword to define constants. Solution: Use the var keyword uniformly to define constants.
7. Problem with input.type attribute
Problem description: The input.type attribute under IE is read-only; but under Firefox, the input.type attribute is read-write. Solution: Do not modify the input.type attribute. If you must modify it, you can hide the original input first, and then insert a new input element at the same position.
8. Window.event problem
Problem description: window.event can only run under IE, but not under Firefox. This is because of Firefox’s event May only be used at the scene of the incident. Solution: Add the event parameter to the function where the event occurs, and use var myEvent = evt?evt:(window.event?window.event:null) in the function body (assuming the formal parameter is evt) Example :
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