1. Document. Form. Item Problems
1) existing problems:
ExistingCodeThere are many statements such as document. formname. Item ("itemname"), which cannot be run in MF.
2) solution:
Use document. formname. elements ["elementname"]
2. Collection class Object Problems
1) existing problems:
In the existing Code, many collection class objects are used (), which is acceptable to IE and cannot be used by MF.
2) solution:
Use [] as the subscript operation. For example, change document. Forms ("formname") to document. Forms ["formname"].
For example, change document. getelementsbyname ("inputname") (1) to document. getelementsbyname ("inputname") [1]
3. Window. Event
1) existing problems:
Window. event cannot be run on MF.
2) solution:
Mf events can only be used in the event. This problem cannot be solved. This can be changed as follows:
Original code (can be run in IE ):
<Input type = "button" name = "somebutton" value = "Submit" nclick = "javascript.: gotosubmit ()"/>
...
<Script. Language = "JavaScript">
Function gotosubmit (){
...
Alert (window. Event); // use window. Event
...
}
</SCRIPT>
New Code (run in IE and MF ):
<Input type = "button" name = "somebutton" value = "Submit" nclick = "javascript.: gotosubmit (event)"/>
...
<Script. Language = "JavaScript">
Function gotosubmit (EVT ){
EVT = EVT? EVT: (window. event? Window. Event: NULL );
...
Alert (EVT); // use EVT
...
}
</SCRIPT>
In addition, if the first line of the new Code is not modified, it is the same as the old code (that is, the gotosubmit call does not provide a parameter), it can only be run in IE, but no error occurs. Therefore, the TPL part of this solution is still compatible with the old code.
Better method:
Function getevent () // compatible with both IE and FF
{
If (document. All) return window. event;
Func = getevent. Caller;
While (func! = NULL ){
VaR arg0 = func. Arguments [0];
If (arg0 ){
If (arg0.constructor = event | arg0.constructor = mouseevent) | (typeof (arg0) = "object" & arg0.preventdefault & arg0.stoppropagation )){
Return arg0;
}
}
Func = func. Caller;
}
Return NULL;
}
Getevent () returns the event parameters. Call this function where it is used.
4. Question about the ID of an HTML object as the object name
1) Existing Problems
In ie, the ID of the HTML object can be directly used as the variable name of the subordinate object of the document. It cannot be in MF.
2) Solution
Use getelementbyid ("idname") instead of idname as the object variable.
5. The problem of getting an object using the idname string
1) Existing Problems
In IE, Eval (idname) can be used to obtain the HTML object with ID as idname, which cannot be used in MF.
2) Solution
Use getelementbyid (idname) instead of eval (idname ).
6. The variable name is the same as the ID of an HTML object.
1) Existing Problems
In MF, because the Object ID is not the name of the HTML object, you can use the same variable name as the HTML Object ID, which cannot be used in IE.
2) Solution
When declaring variables, add VaR to avoid ambiguity, so that it 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.
(3) Others
See question 4
7. event. X and event. Y
1) Existing Problems
In ie, the event object has the X and Y attributes, and MF does not.
2) Solution
In MF, event. X is equivalent to event. pagex. But event. pagex IE does not.
Therefore, event. clientx is used instead of event. X. This variable is also available in IE.
Event. clientx is slightly different from event. pagex (when the page has a scroll bar), but most of the time it is equivalent.
If it is the same, it may be a little troublesome:
MX = event. X? Event. X: event. pagex;
Use MX instead of event. x
(3) Others
Event. layerx is available in both IE and MF. There is no difference in the specific significance of this function.
8. About Frame
1) Existing Problems
In ie, the frame can be obtained using window. testframe, but not in MF.
2) Solution
The main difference between MF and IE in frame usage is:
If the following attributes are written in the frame tag:
<Frame. src = "xx.htm" id = "frameid" name = "framename"/>
Then Ie can access the window object corresponding to this frame through ID or name.
However, MF can only access the window object corresponding to this frame through name.
For example, if the above frame label is written in the HTM in the top window, you can access
IE: window. Top. frameid or window. Top. framename to access this window object
Mf: only window. Top. framename can access this window object.
In addition, both mfand iecan use javasdesktop.doc ument. getelementbyid ("frameid") to access the frame tag.
In addition, you can switch the frame content through the parameter top.doc ument. getelementbyid ("testframe"). src = 'xx.htm '.
You can also switch the frame content through window. Top. framename. Location = 'xx.htm '.
9. In MF, attributes defined by myself must be obtained by getattribute ().
10. If there is no parentelement parement. Children in MF, use
Parentnode. childnodes
Childnodes has different meanings in IE and MF. MF uses Dom specifications, and blank text nodes are inserted in childnodes.
You can avoid this problem by using node. getelementsbytagname.
When a node in HTML is missing, ie and MF have different interpretations of parentnode, for example
<Form>
<Table>
<Input/>
</Table>
</Form>
In MF, the value of input. parentnode is form, while that of input. parentnode in IE is empty.
The node in MF does not have the removenode method. You must use the following method: node. parentnode. removechild (node)
11. Const Problems
1) existing problems:
You cannot use the const keyword in IE. For example, const constvar = 32; in IE, This Is A syntax error.
2) solution:
Use VaR instead of Const.
12. Body object
The MF body exists before the body tag is fully read by the browser, While IE exists only after the body is fully read.
13. url Encoding
In JS, if the URL is written, write directly & do not write & amp; for example, VAR url = 'xx. jsp? Objectname = XX & amp; objectevent = XXX ';
FRM. Action = URL, so it is very likely that the URL will not be properly displayed, so that the parameter is not correctly transmitted to the server.
Generally, the server reports that the error parameter is not found.
Of course, if it is an exception in TPL, because TPL complies with the XML specification and requires & writes as & amp;
Generally, MF cannot identify & amp;
14. nodename and tagname Problems
1) existing problems:
In MF, all nodes have a nodename value, but textnode does not have a tagname value. In IE, nodename usage seems to be
There is a problem (the test is not performed, but my IE has been killed several times ).
2) solution:
Use tagname, but check whether it is empty.
15. Element attributes
The input. Type attribute in IE is read-only, but can be modified in MF.
**************************************** ********
1. When an object is invisible, you cannot set its focus in IE, but in Firefox, you can
2. append rows to a table:
In ff, Safari, opera, and other browsers, use document. createelement to create a row and then use document. appendchild to add the row directly to the table. But not in IE, and
There is no error message. At this time, you need to add the table body (tbody) to the table, and then add the newly created rows to the table body (tbody ),
3. childnodes: Firefox sets the blank space after the carriage returnComposition This node, While IE is not
4. innertext is the proprietary method of IE, textcontent is the proprietary method of Firefox, and innerhtml is both compatible.
5. Set the Style Class Name of a Node object.
In IE, set the class of a node to "classname" as ATTR to set or get.
Ff and other browsers use "class" as ATTR to set or get.
6. event object. Ie uses window. event, FF uses event
7. Event action object. Ieuses objevent.srcelement, and ffuses objevent.tar get
8. Document. Form. item.
Document. formname. Item ("itemname") in IE ")
Use document. formname. elements ["elementname"] in ff.
9. Use () when using a collection class object, ie can accept, MF cannot. Solution: use [] as the subscript.
10. Window. event cannot be run on ff.
11. Question about the ID of an HTML object as the object name
Existing Problem: in IE, the ID of the HTML object can be directly used as the variable name of the subordinate object of the document. It cannot be in ff.
Solution: Use getelementbyid ("idname") instead of idname as the object variable.
11. The variable name is the same as the ID of an HTML object.
Existing Problem: In ff, the Object ID is not the name of the HTML object, so you can use the same variable name as the HTML Object ID, which cannot be
Solution: When declaring variables, add VaR to avoid ambiguity, so that it can run normally in IE. In addition, it is best not to take the variable name that is the same as the HTML Object ID
Reduce errors
12. event. X and event. Y
Existing Problem: in IE, the event object has the X, Y attributes, and FF attributes.
Solution:
In ff, event. X is equivalent to event. pagex. But event. pagex IE does not.
Therefore, event. clientx is used instead of event. X. This variable is also available in IE.
Event. clientx is slightly different from event. pagex (when the page has a scroll bar), but most of the time it is equivalent.
If it is the same, it may be a little troublesome: MX = event. X? Event. X: event. pagex; then use MX instead of event. x
13. parent node Problems
In ff, parentelement parement. Children is used instead of parentnode. childnodes. Childnodes has different meanings in IE and ff.
With DOM specification, blank text nodes are inserted in childnodes. You can avoid this problem by using node. getelementsbytagname.
14. Const Problems
Existing Problem: you cannot use the const keyword in IE. For example, const constvar = 32; in IE, This Is A syntax error.
Solution: use VaR instead of Const.
15. Body object
FF's body exists before the body tag is fully read by the browser, While IE exists only after the body is fully read.
16. nodename and tagname Problems
Existing Problem: In ff, all nodes have a nodename value, but textnode does not have a tagname value. In IE, nodename usage seems to be faulty.
Solution: Use tagname, but check whether it is empty.
17. Element attributes
The input. Type attribute in IE is read-only, but can be modified in ff.
18. Document. getelementsbyname () and document. All [name] Problems
Existing problems: in IE, getelementsbyname () and document. All [name] cannot be used to obtain DIV elements (whether there are other elements that cannot be retrieved is unknown ).
19. Processing of space characters. According to the HTML standard, the space character is & nbsp ;. In ff, If you mistakenly write & nbsp (with a semicolon missing), it will not be considered as a space by Firefox,
Firefox considers it as & nbsp. In IE, If you mistakenly write & nbsp (with a semicolon missing), ie may think it is a space.
20. process the annotation.
According to the HTML standard, the Comment operation is placed in <! -- And -->, and the annotation cannot contain --; otherwise, an HTML parsing error occurs.
**************************************** ************
1. Organization issues
Problem: the IE value of any distance can be left with no unit. The FF value must be written in units (except 0)
Solution: Write All units such as padding: 0px;
2. horizontal center
Problem: For content in Div, ie is center by default, and FF is left by default.
Solution: mairgin: 0px auto;
3. High Problems
Problem: If the height of a div is set, when the actual content in the DIV is greater than the height, ie will automatically stretch to adapt to the size of the DIV container, and FF will fix the DIV's instructions, if the part exceeds the bottom line of the DIV, it overlaps with the following content.
Solution: control the appropriate height, or disable writing, so that the browser can automatically adjust the height, or set overflow: hidden;
4. Clear: both;
Problem: If the n-column div is controlled by float, ie will automatically check the automatic arrangement below, and FF may be unhonest and messy everywhere.
Solution: add clear: both to the next label after the float ends to end the float control.
5. Maximum/small width Problem
Problem: Min-width and max-width are only FF commands. How can I make ie achieve the same effect?
Solution: IE does not know Min-And Max-. ie actually thinks that Min-width, Max-width, and width have the same effect. You can solve this problem using the following method:
# Cctext {
Min-width: 700px;
Max-width: 1000px;
Width: expression (document. Body. clientwidth <700? & Quot; 700px & quot;: Document. Body. clientwidth & gt; 1000? "1000px": "Auto ");
}
6 ,! Important Support
Problem: FF does not support IE
Solution: none. IE will ignore.
7. cursor status
Problem: cursor: hand; only supported by IE. The Finger status is displayed.
Solution: Both cursor: pointer; IE and FF are supported.
8. Actual pixels
IE/Opera: actual width of the object = (margin-left) + width + (margin-right)
Firefox/Mozilla: actual width of the object = (margin-left) + (border-left-width) + (padding-left) + width + (padding-right) + (border-right-width) + (margin-right)
Therefore, the display width of IE and FF is slightly different when the tables are arranged and columns are arranged.
9,
IE:
Document. getelementbyid ("jqcontextmenu"). style. Left = event. clientx;
Document. getelementbyid ("jqcontextmenu"). style. Top = event. clienty;
Compatible with IE and FF:
Document. getelementbyid ("jqcontextmenu"). style. Left = event. clientx + "PX ";
Document. getelementbyid ("jqcontextmenu"). style. Top = event. clienty + "PX ";
This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/tengyang11/archive/2011/01/07/6122717.aspx