Browser JS differences

Source: Internet
Author: User

1, float:

IE Syntax: <br/> document. getelementbyid ("Header "). style. stylefloat = "Left"; <br/> Firefox Syntax: <br/> document.getelementbyid(?header=}.style.css float = "Left "; 

2. javascript can easily obtain and modify the CSS style of an object through object. style. Property, which is limited to inline styles.

IE Syntax: <br/> var myobject = document. getelementbyid ("Header"); <br/> var mystyle = myobject. currentstyle. backgroundcolor; <br/> Firefox Syntax: <br/> var myobject = document. getelementbyid ("Header"); <br/> var mycomputedstyle = document. defaultview. getcomputedstyle (myobject, null); <br/> var mystyle = mycomputedstyle. backgroundcolor; 

3. class attributes

IE Syntax: <br/> var myobject = document. getelementbyid ("Header"); <br/> var myattribute = myobject. getattribute ("classname"); <br/> Firefox Syntax: <br/> var myobject = document. getelementbyid ("Header"); <br/> var myattribute = myobject. getattribute ("class "); 

4. Obtain the "for" attribute of the label.

IE Syntax: <br/> var myobject = document. getelementbyid ("mylabel"); <br/> var myattribute = myobject. getattribute ("htmlfor"); <br/> Firefox Syntax: <br/> var myobject = document. getelementbyid ("mylabel"); <br/> var myattribute = myobject. getattribute (""); 

5. Obtain the cursor position

IE Syntax: <br/> var mycursorposition = [0, 0]; <br/> mycursorposition [0] = event. clientx; <br/> mycursorposition [1] = event. clienty; <br/> Firefox Syntax: <br/> var mycursorposition = [0, 0]; <br/> mycursorposition [0] = event. pagex; <br/> mycursorposition [1] = event. pagey; 

6. Obtain the size of the window or browser window.

IE Syntax: <br/> var mybrowsersize = [0, 0]; <br/> mybrowsersize [0] = document.doc umentelement. clientwidth; <br/> mybrowsersize [1] = document.doc umentelement. clientheight; <br/> Firefox Syntax: <br/> var mybrowsersize = [0, 0]; <br/> mybrowsersize [0] = Window. innerwidth; <br/> mybrowsersize [1] = Window. innerheight; 

7. Alpha transparency

IE Syntax: <br/> var myobject = document. getelementbyid ("myelement"); <br/> myobject. style. filter = "alpha (opacity = 80)"; <br/> Firefox Syntax: <br/> var myobject = document. getelementbyid ("myelement"); <br/> myobject. style. opacity = 0.5 ″; 

 

To: http://www.rainweb.cn/article/232.html

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.