Differences between IE and firefox in javascript and css

Source: Internet
Author: User

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 required, you can use innerHTML instead if the string does not contain HTML code.

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:

Reference content is as follows:
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.

  • 2 pages in total:
  • Previous Page
  • 1
  • 2
  • Next Page

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.