JavaScript commonly used compatibility writing process detailed

Source: Internet
Author: User


The most basic syntax for accessing a given CSS value is: Object.style.property, such as: Object.style.backgroundcolor= "#ccc"; However, if you access the Float property, it is not the same, because float itself is the reserved keyword JS, you need to write this:

IE:object.style.styleFloat = "Left";
FF:object.style.cssFloat = "Left";

Class is also a reserved keyword, which can be written like this:
IE:object.getAttribute ("ClassName");

FF:object.getAttribute ("class");

Window.event Object Differences
IE: There are window.event objects
FF: No Window.event object. You can pass an event object to a parameter of a function. such as Onmousemove=domousemove (event)


Get the current coordinates of the mouse

Ie:event.x and Event.y.
FF:event.pageX and Event.pagey.
General: Both have Event.clientx and Event.clienty attributes.


The current coordinates of the mouse (plus the distance the scroll bar rolls over)
IE:event.offsetX and Event.offsety.
FF:event.layerX and Event.layery.


Coordinates of the x and Y of the label: Style.posleft and Style.postop
IE: there is.
FF: No.
General: Object.offsetleft and Object.offsettop.


Get the height and width of a form
IE:document.body.offsetWidth and Document.body.offsetHeight. (the page must have a body tag)
FF:window.innerWidth and Window.innerhegiht, as well as Document.documentElement.clientWidth and document.documentElement.clientHeight.
General: Document.body.clientWidth and Document.body.clientHeight.

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.