<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<head><meta forua="true" http-equiv="Cache-Control" content="max-age=0" /></head>
<card title="IE与Firefox在JavaScript上的7个不同语法" id="card1">
<p> 游客</p><p>
标题:IE与Firefox在JavaScript上的7个不同语法<br/>
正文:<br/>
1. CSS &amp;quot;float&amp;quot; 值访问一个给定CSS 值的最基本句法是：object.style.property，使用驼峰写法来替换有连接符的值，例如，访问某个ID为&amp;quot;header&amp;quot;的&amp;lt;div&amp;gt;的 background-color值，我们使用如下句法：document.getElementById(&amp;quot;header&amp;quot;).style.backgroundColor= &amp;quot;#ccc&amp;quot;;但由于&amp;quot;float&amp;quot;这个词是一个JavaScript保留字，因此我们不能用 object.style.float来访问，这里，我们可以在两种浏览器中这么做：在IE中这样写：document.getElementById(&amp;quot;header&amp;quot;).style.styleFloat = &amp;quot;left&amp;quot;;在Firefox中这样写：document.getElementById(&amp;quot;header&amp;quot;).style.cssFloat = &amp;quot;left&amp;quot;;2. 元素的推算样式JavaScript可以使用object.style.property句法，方便地在外部访问和修改某个CSS样式，但其限制是这些句法只能取出已设的行内样式或者直接由JavaScript设定的样式。并不能访问某个外部的样式表。为了访问元素的&amp;quot;推算&amp;quot;样式，我们可以使用下面的代码：在IE中这样写：var myObject = document.getElementById(&amp;quot;header&amp;quot;);var myStyle = myObject.currentStyle.backgroundColor;在Firefox中这样写：var myObject = document.getElementById(&amp;quot;header&amp;quot;);var myComputedStyle = document.defaultView.getComputedStyle(myObject, null);var myStyle = myComputedStyle.backgroundColor;3. 访问元素的&amp;quot;class&amp;quot;像<br/><a href="http://haidanet.cn/Blog/wap.asp?mode=WAP&amp;act=View&amp;id=29&amp;Page=1">[&lt;&lt;]</a><a href="http://haidanet.cn/Blog/wap.asp?mode=WAP&amp;act=View&amp;id=29&amp;Page=1">[[1]]</a><a href="http://haidanet.cn/Blog/wap.asp?mode=WAP&amp;act=View&amp;id=29&amp;Page=2">[2]</a><a href="http://haidanet.cn/Blog/wap.asp?mode=WAP&amp;act=View&amp;id=29&amp;Page=3">[3]</a><a href="http://haidanet.cn/Blog/wap.asp?mode=WAP&amp;act=View&amp;id=29&amp;Page=3">[&gt;&gt;]</a><br/>
<br/>
<a href="wap.asp?act=Com&amp;id=29">查看评论(0)</a><br/>
<a href="wap.asp?act=AddCom&amp;inpId=29">发表评论</a><br/><br/>

<br/>

<br/>
<a href="http://haidanet.cn/Blog/wap.asp">首页</a>
</p>
</card>
</wml>