I found several differences between IE and Firefox JS and CSS.

Source: Internet
Author: User
I used to write functions in IE, so I wrote some functions in Firefox. I spent a lot of time on Firefox and found some differences between Firefox and IE:

1. Firefox does not support innertext or why. Firefox supports innerhtml but does not support innertext, so I checked it online and changed it to support textcontent to implement innertext. However, the implementation is not so good. By default, extra spaces are retained. If textcontent is not used, if the string does not contain HTMLCodeYou can also use innerhtml instead.

2. Prohibit the selection of webpage content:
JS: obj. onselectstart = function () {return false;} is generally used in IE ;}
Firefox uses CSS:-moz-user-select: None

3. Filter support (for example, transparent filter ):
IE: filter: alpha (opacity = 10 );
Firefox:-moz-opacity:. 10;

4. Capture events:
IE: obj. setcapture (), obj. releasecapture ()
Firefox: Document. addeventlistener ("mousemove", mousemovefunction, true );
Document. removeeventlistener ("mousemove", mousemovefunction, true );


5. Get the mouse position:
IE: event. clientx, event. clienty
Firefox: The event object needs to be passed by the event function.
OBJ. onmousemove = function (EV ){
X = eV. pagex; y = eV. Pagey;
}

6. Limitations of Div and other elements:
For example, set CSS ::{ width: 100px; Height: 100px; Border: #000000 1px solid;} Of a div ;}
In ie: div width (including Border width): 100px, div height (including Border width): 100px;
Firefox: div width (including Border width): 102px, div height (including Border width): 102px;

So when we drag windows compatible with IE and Firefox, we need to use some brains to write JS and CSS, and give you two tips.
1. Determine the browser type:
VaR isie = Document. All? True: false;
I wrote a variable. If the document. All syntax is supported, isie = true; otherwise, isie = false.

2. CSS processing in different browsers:
Generally, it can be used! Important Uses CSS statements first (only supported by Firefox)
For example: {border-width: 0px! Important; border-width: 1px ;}
In Firefox, this element has no border, and the Border Width under IE is 1px.

We also found several differences between XHTML and JavaScript and CSS in normal state.
In the previous phase, I wrote a drag window compatible with IE/Firefox and found several differences between the two browsers: I found several differences between IE and Firefox JS and CSS. [original]
Today, I wrote another version compatible with XHTML, because it is not a popular web standard, so I cannot lag behind! Now all pages in ASP. NET are based on the XHTML standard. If the standard code is deleted from the layout page, the layout and control Visual Studio will not be displayed.
Well, the code added at the beginning of the webpage is the so-called XHTML standard. <! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

I modified JS and CSS and debugged them n times. I found several differences in the XHTML standard:
1.document.doc umentelement and document. Body
You must use: document.doc umentelement to set page CSS in the code.
For example: document.doc umentelement. style. Overflow = 'hidd ';
The two coordinate attributes of overflow-X and overflow-y, XHTML, are not supported;

2.use document.doc umentelement to determine the distance between the obtained webpage window and the selected scroll bar.
The four metrics (clientwidth?clientheight=scrollleft?scrolltop=must use document.doc umentelement
When the parameter umentelement. removechild () is replaced, an error is returned;

* ********* Specify umentelement

3. Haha, after this standard is added, the border problem of IE has also changed. Now it is consistent with Firefox. Is this the advantage of XHTML-cross-browser standards?
Part 1ArticleMentioned:
Set CSS ::{ width: 100px; Height: 100px; Border: #000000 1px solid;} Of a div ;}
IE (normal): div width (including Border width): 100px, div height (including Border width): 100px;
Firefox (normal): div width (including Border width): 102px, div height (including Border width): 102px;

Added the XHTML standard (ie and Firefox ):
In IE (XHTML): div width (including Border width): 102px, div height (including Border width): 102px;
Firefox (XHTML): div width (including Border width): 102px, div height (including Border width): 102px;

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.