Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

7 JavaScript Differences Between Firefox & IE

Although the days of long and tedious code branches to target specific browsers in JavaScript are over, once in a while it's still necessary to do some simple code branching and object detection to ensure that a certain piece of code is working properly on a user's machine. 
In this article, I'll outine 7 areas where Internet Explorer and Firefox differ in JavaScript syntax. In this article, I'll outine 7 areas where Internet Explorer and Firefox differ in JavaScript syntax. 
1. The CSS “float” property 1. The CSS “float” property
The basic syntax for accessing a specific css property for any given object is object.style.property , using camel casing to replace a hyphenated property. For example, to access the background-color property of a The basic syntax for accessing a specific css property for any given object is object.style.property , using camel casing to replace a hyphenated property. For example, to access the background-color property of a
whose ID is “header”, we would use the following syntax: whose ID is “header”, we would use the following syntax: 
document.getElementById( "header" ).style.backgroundColor= "#ccc" ; document.getElementById( "header" ).style.backgroundColor= "#ccc" ; 
But since the word “float” is already reserved for use in JavaScript, we cannot access the “float” property using object.style.float . Here is how we do it in the two browsers: But since the word “float” is already reserved for use in JavaScript, we cannot access the “float” property using object.style.float . Here is how we do it in the two browsers: 
The IE Syntax: The IE Syntax:
document.getElementById( "header" ).style.styleFloat = "left" ; document.getElementById( "header" )


Ïà¹ØÎĵµ£º

javascriptÃæÏò¶ÔÏó±à³Ì

---->ʲôÊÇÀàºÍ¶ÔÏó
ÕâÊÇËùÓÐÃæÏò¶ÔÏó±à³Ì֮ǰ±ØÐëŪÃ÷°×µÄ.
ËùνÀà:¼òµ¥µØËµ¾ÍÊÇÄ£°å,˵µÄרҵһЩ,ÊÇÒ»Àà¾ßÓÐijÖÖÐÔÖʵÄÎïµÄ¼¯ºÏ.±ÈÈç:È˾ÍÊÇÒ»¸öÀà,³µÒ²ÊÇÒ»¸öÀà,µÈµÈ.
Ëùν¶ÔÏó:¾ÍÊÇÀàµÄ¾ßÌåʵÏÖ.ÈçÉÏÃæËù˵,ÈËÊÇÒ»¸öÀà,Ò»¸ö¾ßÌåµÄÈ˾ÍÊÇÒ»¸ö¶ÔÏó,±ÈÈçÕÅÈý.

¶ÔÏóÊÇÀàµÄʵÀý»¯ºóµÄ½á¹û.ja ......

JavaScript¶¯Ì¬Éú³ÉÊ÷Ðβ˵¥´´½¨±í¸ñ

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<head>
<title>ÎÞÏÞ¼¶Ê÷Ð ......

JavaScript ¶¯Ì¬´´½¨±í¸ñ£ºÐÂÔö¡¢É¾³ýÐк͵¥Ôª¸ñ

ÀûÓÃjsÀ´¶¯Ì¬´´½¨±í¸ñÓÐÁ½ÖÖ¸ñʽ£¬appendChild()ºÍinsertRow¡¢insertCell()¡£Á½ÖÖ·½Ê½Æäʵ²î²»¶à£¬µ«µÚÒ»ÖÖÓпÉÄÜÔÚIEÉÏÓÐÎÊÌ⣬ËùÒÔÍÆ¼ö´ó¼ÒʹÓõڶþÖÖÁË£¬Ö±½Ó˵°É¡£
1¡¢inserRow()ºÍinsertCell()º¯Êý
insertRow()º¯Êý¿ÉÒÔ´ø²ÎÊý£¬ÐÎʽÈçÏ£º
insertRow(index)£ºindex´Ó0¿ªÊ¼
¡¡¡¡Õâ¸öº¯Êý½«ÐÂÐÐÌí¼Óµ½indexµÄÄÇÒ»ÐÐÇ ......

JavaScript ¼òµ¥ÏîĿӦÓü¼ÇÉ

1.<select></select>±êǩӦÓÃ
    ͨ³£µÄд·¨ÊÇ£º
    <select onchange="javascript:windwo.open(this.options[this.selectedIndex].value)">
        <option>MAIN</option>
      & ......

javascript ¶¯Ì¬¼ÓÔØcss¡¢js

¼æÈÝIE¡¢FireFox¡¢Chrome
//¼ÓÔØjs
function loadJs(){
    if (!getObj('script_PlData')){
        var scriptObj= document.createElement("script");
        //scriptObj.id = 'script_1';
    &nb ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ