<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>等待-放飞梦想 &#187; Firefox</title>
	<atom:link href="http://leotheme.cn/tag/firefox/feed" rel="self" type="application/rss+xml" />
	<link>http://leotheme.cn</link>
	<description>勤现在-乐将来</description>
	<lastBuildDate>Mon, 21 May 2012 09:45:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>firefox与ie 的javascript区别</title>
		<link>http://leotheme.cn/javascript/firefox-and-ie-javascript.html</link>
		<comments>http://leotheme.cn/javascript/firefox-and-ie-javascript.html#comments</comments>
		<pubDate>Tue, 10 Aug 2010 14:09:02 +0000</pubDate>
		<dc:creator>Await</dc:creator>
				<category><![CDATA[前端交互]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[IE]]></category>

		<guid isPermaLink="false">http://leotheme.cn/?p=792</guid>
		<description><![CDATA[浏览器的兼容问题目前还是一个头痛的问题。除了CSS的兼容性，Javascript的兼容有时候更容易让人头痛。下面收集的一些关于Firefox和IE的区别作个记号，需要的时候看看 1. Document.form.item 问题 现有问题： 现有代码中存在许多 document.formName.item(“itemName”) 这样的语句，不能在 firefox下运行 解决方法： 改用 document.formName.elements["elementName"] 2. 集合类对象问题 现有问题： 现有代码中许多集合类对象取用时使用 ()，IE 能接受，firefox 不能。 解决方法： 改用 [] 作为下标运算。如：document.forms(“formName”) 改为 document.forms["formName"]。 又如：document.getElementsByName(“inputName”)(1) 改为 document.getElementsByName(“inputName”)[1] 3. window.event (1)现有问题： 使用 window.event 无法在 mf 上运行 (2)解决方法： mf 的 event 只能在事件发生的现场使用，此问题暂无法解决。可以这样变通： 原代码(可在ie中运行)： 原代码(可在IE中运行)： &#60;input type=&#34;button&#34; name=&#34;someButton&#34; value=&#34;提交&#34; onclick=&#34;javascript:gotoSubmit()&#34;/&#62;&#160;&#160; &#160; &#160; &#160; &#160; &#160;...&#160;&#160; &#160; &#160; [...]<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="能支持IE6的前端更牛，还是敢对IE6说不的更牛？" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fie6-must-die.html&from=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Ffirefox-and-ie-javascript.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/04/22/6197236.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">能支持IE6的前端更牛，还是敢对IE6说不的更牛？</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="IE6因为编码问题无法正确解析CSS文件" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fie6-css-zhusi.html&from=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Ffirefox-and-ie-javascript.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">IE6因为编码问题无法正确解析CSS文件</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="CSS样式中class和id的区别和含义" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fstyleforcssandidequbie.html&from=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Ffirefox-and-ie-javascript.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">CSS样式中class和id的区别和含义</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="最佳网页IE浏览器兼容性测试工具(IE6 IE7 IE8共存)" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fietester.html&from=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Ffirefox-and-ie-javascript.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/04/22/6199374.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">最佳网页IE浏览器兼容性测试工具(IE6 IE7 IE8共存)</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="IE下中英文字体不能对齐原因及解决" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fiexiazywbunenduiji.html&from=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Ffirefox-and-ie-javascript.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">IE下中英文字体不能对齐原因及解决</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>浏览器的兼容问题目前还是一个头痛的问题。除了CSS的兼容性，Javascript的兼容有时候更容易让人头痛。下面收集的一些关于Firefox和IE的区别作个记号，需要的时候看看</p>
<p><strong>1. Document.form.item 问题</strong><br />
    现有问题：<br />
       现有代码中存在许多 document.formName.item(“itemName”) 这样的语句，不能在 firefox下运行<br />
 <span id="more-792"></span><br />
    解决方法：<br />
        改用 document.formName.elements["elementName"]</p>
<p><strong>2. 集合类对象问题</strong><br />
    现有问题：<br />
        现有代码中许多集合类对象取用时使用 ()，IE 能接受，firefox 不能。<br />
    解决方法：<br />
        改用 [] 作为下标运算。如：document.forms(“formName”) 改为 document.forms["formName"]。<br />
        又如：document.getElementsByName(“inputName”)(1) 改为 document.getElementsByName(“inputName”)[1]</p>
<p><strong>3. window.event</strong><br />
    (1)现有问题：<br />
使用 <code>window.event </code>无法在 mf 上运行<br />
(2)解决方法：<br />
mf 的 <code>event</code> 只能在事件发生的现场使用，此问题暂无法解决。可以这样变通：<br />
原代码(可在ie中运行)：<br />
        原代码(可在IE中运行)：</p>
<div class="hl-surround"><div class="hl-main"><span style="color: Gray;">&lt;</span><span style="color: Blue;">input</span><span style="color: Gray;"> </span><span style="color: Blue;">type</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">button</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: Blue;">name</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">someButton</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: Blue;">value</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">提交</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: Blue;">onclick</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">javascript:gotoSubmit()</span><span style="color: #8b0000;">&quot;/</span><span style="color: Red;">&gt;<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;...<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;script language=&quot;javascript&quot;&gt;<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;function gotoSubmit() {<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;...<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;alert(window.event);&nbsp; &nbsp; </span><span style="color: #8b0000;">//</span><span style="color: Red;"> use window.event<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;...<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;</span><span style="color: #8b0000;">/</span><span style="color: Blue;">script</span><span style="color: Gray;">&gt;</span></div></div>
<p>        新代码(可在IE和MF中运行)：</p>
<div class="hl-surround"><div class="hl-main"><span style="color: Gray;">&lt;</span><span style="color: Blue;">input</span><span style="color: Gray;"> </span><span style="color: Blue;">type</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">button</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: Blue;">name</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">someButton</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: Blue;">value</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">提交</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: Blue;">onclick</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">javascript:gotoSubmit(event)</span><span style="color: #8b0000;">&quot;/</span><span style="color: Red;">&gt;<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;...<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;script language=&quot;javascript&quot;&gt;<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;function gotoSubmit(evt) {<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;evt = evt ? evt : (window.event ? window.event : null);<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;...<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;alert(evt);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #8b0000;">//</span><span style="color: Red;"> use evt<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;...<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;</span><span style="color: #8b0000;">/</span><span style="color: Blue;">script</span><span style="color: Gray;">&gt;</span></div></div>
<p>        此外，如果新代码中第一行不改，与老代码一样的话(即 gotoSubmit 调用没有给参数)，则仍然只能在IE中运行，但不会出错。所以，这种方案 tpl 部分仍与老代码兼容。</p>
<p><strong>4. HTML 对象的 id 作为对象名的问题</strong><br />
    现有问题<br />
        在 IE 中，HTML 对象的 ID 可以作为 document 的下属对象变量名直接使用。在 firefox 中不能。<br />
    解决方法<br />
        用 getElementById(“idName”) 代替 idName 作为对象变量使用。</p>
<p><strong>5. 用idName字符串取得对象的问题</strong><br />
    现有问题<br />
        在IE中，利用 eval(idName) 可以取得 id 为 idName 的 HTML 对象，在MF 中不能。<br />
    解决方法<br />
        用 getElementById(idName) 代替 eval(idName)。</p>
<p><strong>6. 变量名与某 HTML 对象 id 相同的问题</strong><br />
    现有问题<br />
        在 MF 中，因为对象 id 不作为 HTML 对象的名称，所以可以使用与 HTML 对象 id 相同的变量名，IE 中不能。<br />
    解决方法<br />
        在声明变量时，一律加上 var ，以避免歧义，这样在 IE 中亦可正常运行。<br />
        此外，最好不要取与 HTML 对象 id 相同的变量名，以减少错误。</p>
<p><strong>7. event.x 与 event.y 问题</strong><br />
    现有问题<br />
        在IE 中，event 对象有 x, y 属性，MF中没有。<br />
    解决方法<br />
        在MF中，与event.x 等效的是 event.pageX。但event.pageX IE中没有。<br />
        故采用 event.clientX 代替 event.x。在IE 中也有这个变量。<br />
        event.clientX 与 event.pageX 有微妙的差别（当整个页面有滚动条的时候），不过大多数时候是等效的。</p>
<p>        如果要完全一样，可以稍麻烦些：<br />
        mX = event.x ? event.x : event.pageX;<br />
        然后用 mX 代替 event.x<br />
    其它<br />
        event.layerX 在 IE 与 MF 中都有，具体意义有无差别尚未试验。</p>
<p> <strong>8. 关于frame</strong><br />
   现有问题<br />
         在 IE中 可以用window.testFrame取得该frame，mf中不行<br />
   解决方法<br />
         在frame的使用方面mf和ie的最主要的区别是：<br />
如果在frame标签中书写了以下属性：</p>
<div class="hl-surround"><div class="hl-main"><span style="color: Olive;">&lt;</span><span style="color: Green;">frame</span><span style="color: Gray;"> </span><span style="color: #00008b;">src</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">xx.htm</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">id</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">frameId</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">name</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">frameName</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: Olive;">/&gt;</span></div></div>
<p>那么ie可以通过id或者name访问这个frame对应的window对象<br />
而mf只可以通过name来访问这个frame对应的window对象<br />
例如如果上述frame标签写在最上层的window里面的htm里面，那么可以这样访问<br />
ie： window.top.frameId或者window.top.frameName来访问这个window对象<br />
mf： 只能这样window.top.frameName来访问这个window对象</p>
<p>另外，在mf和ie中都可以使用window.top.document.getElementById(“frameId”)来访问frame标签<br />
并且可以通过window.top.document.getElementById(“testFrame”).src = &#8216;xx.htm&#8217;来切换frame的内容<br />
也都可以通过window.top.frameName.location = &#8216;xx.htm&#8217;来切换frame的内容<br />
关于frame和window的描述可以参见bbs的‘window与frame’文章<br />
以及/test/js/test_frame/目录下面的测试</p>
<p><strong>9. 在mf中，自己定义的属性必须getAttribute()取得</strong><br />
<strong>10.在mf中没有 parentElement parement.children 而用 parentNode parentNode.childNodes</strong><br />
   childNodes的下标的含义在IE和MF中不同，MF使用DOM规范，childNodes中会插入空白文本节点。一般可以通过node.getElementsByTagName()来回避这个问题。 当html中节点缺失时，IE和MF对parentNode的解释不同，例如</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span style="color: Olive;">&lt;</span><span style="color: Green;">form</span><span style="color: Olive;">&gt;</span></li>
<li><span style="color: Gray;">&nbsp;&nbsp; </span><span style="color: Olive;">&lt;</span><span style="color: Green;">table</span><span style="color: Olive;">&gt;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">&lt;</span><span style="color: Green;">input</span><span style="color: Olive;">/&gt;</span></li>
<li><span style="color: Gray;">&nbsp;&nbsp; </span><span style="color: Olive;">&lt;/</span><span style="color: Green;">table</span><span style="color: Olive;">&gt;</span></li>
<li><span style="color: Gray;">&nbsp;&nbsp; </span><span style="color: Olive;">&lt;/</span><span style="color: Green;">form</span><span style="color: Olive;">&gt;</span></li></ol></div>
<p>   MF中input.parentNode的值为form, 而IE中input.parentNode的值为空节点</p>
<p> MF中节点没有removeNode方法，必须使用如下方法 node.parentNode.removeChild(node)</p>
<p><strong>11.const 问题</strong><br />
 现有问题:<br />
     在 IE 中不能使用 const 关键字。如 const constVar = 32; 在IE中这是语法错误。<br />
 解决方法:<br />
     不使用 const ，以 var 代替。</p>
<p><strong>12. body 对象</strong><br />
   MF的body在body标签没有被浏览器完全读入之前就存在，而IE则必须在body完全被读入之后才存在</p>
<p><strong>13. url encoding</strong><br />
在js中如果书写url就直接写&#038;不要写&amp;例如var url = &#8216;xx.jsp?objectName=xx&amp;objectEvent=xxx&#8217;;<br />
frm.action = url那么很有可能url不会被正常显示以至于参数没有正确的传到服务器<br />
一般会服务器报错参数没有找到<br />
当然如果是在tpl中例外，因为tpl中符合xml规范，要求&#038;书写为&amp;<br />
一般MF无法识别js中的&amp;</p>
<p><strong>14. nodeName 和 tagName 问题</strong><br />
 现有问题：<br />
     在MF中，所有节点均有 nodeName 值，但 textNode 没有 tagName 值。在 IE 中，nodeName 的使用好象<br />
     有问题（具体情况没有测试，但我的IE已经死了好几次）。<br />
 解决方法：<br />
     使用 tagName，但应检测其是否为空。</p>
<p><strong>15. 元素属性</strong><br />
   IE下 input.type属性为只读，但是MF下可以修改</p>
<p><strong>16. document.getElementsByName() 和 document.all[name] 的问题</strong><br />
 现有问题：<br />
     在 IE 中，getElementsByName()、document.all[name] 均不能用来取得 div 元素（是否还有其它不能取的元素还不知道）。</p>
<p> <strong>17. 对象问题</strong><br />
1.1 Form对象<br />
现有问题：<br />
现有代码这获得form对象通过document.forms(“formName”)，这样使用在IE 能接受，MF 不能。<br />
解决方法：<br />
改用 作为下标运算。改为document.forms["formName"]<br />
备注<br />
上述的改用 作为下标运算中的formName是id而name</p>
<p>1.2 HTML对象<br />
现有问题：<br />
在 IE 中，HTML 对象的 ID 可以作为 document 的下属对象变量名直接使用。在 MF 中不能。<br />
document.all(“itemName”)或者document.all(“itemId”)<br />
解决方法：<br />
使用对象ID作为对象变量名<br />
<code>document.getElementById("itemId")</code><br />
备注<br />
document.all是IE自定义的方法，所以请大家尽量不使用。<br />
还有一种方式，在IE和MF都可以使用<br />
<code>var f = document.forms["formName "];<br />
var o = f. itemId;</code></p>
<p>1.3 DIV对象<br />
现有问题：<br />
在 IE 中，DIV对象可以使用ID作为对象变量名直接使用。在 MF 中不能。<br />
DivId.style.display = “none”<br />
解决方法：<br />
document.getElementById(“DivId”).style.display = “none”<br />
备注<br />
获得对象的方法不管是不是DIV对象，都使用getElementById方法。参见1.2</p>
<p>1.4 关于frame<br />
现有问题<br />
在 IE中 可以用window.testFrame取得该frame，mf中不行<br />
解决方法<br />
在frame的使用方面MF和IE的最主要的区别是：<br />
如果在frame标签中书写了以下属性：</p>
<p>那么IE可以通过id或者name访问这个frame对应的window对象<br />
而mf只可以通过name来访问这个frame对应的window对象<br />
例如如果上述frame标签写在最上层的window里面的htm里面，那么可以这样访问<br />
IE： window.top.frameId或者window.top.frameName来访问这个window对象<br />
MF：只能这样window.top.frameName来访问这个window对象<br />
另外，在mf和ie中都可以使用window.top.document.getElementById(“frameId”)来访问frame标签<br />
并且可以通过window.top.document.getElementById(“testFrame”).src = &#8216;xx.htm&#8217;来切换frame的内容<br />
也都可以通过window.top.frameName.location = &#8216;xx.htm&#8217;来切换frame的内容</p>
<p>1.5 窗口<br />
现有问题<br />
IE中可以通过showModalDialog和showModelessDialog打开模态和非模态窗口，但是MF不支持。<br />
解决办法<br />
直接使用window.open(pageURL,name,parameters)方式打开新窗口。<br />
如果需要传递参数，可以使用frame或者iframe。</p>
<p>2. 总结<br />
2.1 在JS中定义各种对象变量名时，尽量使用id，避免使用name。<br />
在 IE 中，HTML 对象的 ID 可以作为 document 的下属对象变量名直接使用。在 MF 中不能，所以在平常使用时请尽量使用id，避免只使用name，而不使用id。</p>
<p>2.2 变量名与某 HTML 对象 id 相同的问题<br />
现有问题<br />
在 MF 中，因为对象 id 不作为 HTML 对象的名称，所以可以使用与 HTML 对象 id 相同的变量名，IE 中不能。<br />
解决方法<br />
在声明变量时，一律加上 var ，以避免歧义，这样在 IE 中亦可正常运行。<br />
此外，最好不要取与 HTML 对象 id 相同的变量名，以减少错误。</p>
<p>1. document.all<br />
 Firefox可以兼容document.all， 但会生成一条警告。可以用getElementById(“*”) 或者 getElementByTagName(“*)来代替<br />
 不过对于document.all.length等属性，则完全不兼容。<br />
2. parentElement<br />
 这个也不兼容。比方说， obj.parentElement.name 则应改成 obj.parentNode.attributes.getNamedItem(“name”).nodeValue （不知道如何写得更简洁些）<br />
3. event<br />
 W3C不支持windows.event<br />
 比方说:<br />
    在IE里面</p>
<div class="hl-surround"><div class="hl-main"><span style="color: Olive;">&lt;</span><span style="color: Green;">div</span><span style="color: Gray;"> </span><span style="color: #00008b;">class</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">menu</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">id</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">menu</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">onclick</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">onMenuClick(); </span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">&gt;</span><span style="color: Gray;">.....</span><span style="color: Olive;">&lt;/</span><span style="color: Green;">div</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp; &nbsp;function onMenuClick()<br />&nbsp;&nbsp; &nbsp; &nbsp;{<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;collapseMenu(event.srcElement);<br />&nbsp;&nbsp; &nbsp; &nbsp;}</span></div></div>
<p>    工作正常。不过在Firefox中，则改成：</p>
<div class="hl-surround"><div class="hl-main"><span style="color: Olive;">&lt;</span><span style="color: Green;">div</span><span style="color: Gray;"> </span><span style="color: #00008b;">class</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">menu</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">id</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">menu</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">onclick</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">onMenuClick(event); </span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;function onMenuClick(evt)<br />&nbsp;&nbsp; &nbsp; &nbsp;{<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if(evt == null)<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;evt = window.event; // For IE<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;var srcElement = evt.srcElement? evt.srcElement : evt.target; // IE使用srcElement, 而Firefox使用target<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;collapseMenu(srcElement);<br />}</span></div></div>
<p>1：innerText<br />
IE支持，FIREFOX不支持<br />
解决办法：用innerHTML,2种浏览器都识别innerHTML</p>
<p>2：document.createElement<br />
document.appendChild<br />
在往表里插入行时<br />
FIREFOX支持，IE不支持<br />
解决办法：把行插入到TBODY中，不要直接插入到表</p>
<p>3：setAttribute(&#8216;style&#8217;,'color:red;&#8217;)<br />
FIREFOX支持(除了IE，现在所有浏览器都支持)，IE不支持<br />
解决办法：不用setAttribute(&#8216;style&#8217;,'color:red&#8217;)<br />
而用object.style.cssText = &#8216;color:red;&#8217;(这写法也有例外)<br />
最好的办法是上面种方法都用上，万无一失 ^_^<br />
4:class<br />
setAttribute(&#8216;class&#8217;,'styleClass&#8217;)<br />
FIREFOX支持，IE不支持(指定属性名为CLASS，IE不会设置元素的CLASS属性，相反只使用SETATTRIBUTE时IE自动识别CLASSNAME属性)<br />
解决办法：<br />
setAttribute(&#8216;class&#8217;,'styleClass&#8217;)<br />
setAttribute(&#8216;className&#8217;,'styleClass&#8217;)<br />
2种都用上</p>
<p>5:用setAttribute设置事件<br />
var obj = document.getElementById(&#8216;objId&#8217;);<br />
obj.setAttribute(&#8216;onclick&#8217;,'funcitonname();&#8217;);<br />
FIREFOX支持，IE不支持<br />
解决办法：<br />
IE中必须用点记法来引用所需的事件处理程序,并且要用赋予匿名函数<br />
如下：<br />
var obj = document.getElementById(&#8216;objId&#8217;);<br />
obj.onclick=function(){fucntionname();};<br />
这种方法所有浏览器都支持</p>
<p>6：建立单选钮<br />
IE以外的浏览器</p>
<div class="hl-surround"><div class="hl-main"><span style="color: Green;">var</span><span style="color: Gray;"> </span><span style="color: Blue;">rdo</span><span style="color: Gray;"> = </span><span style="color: Teal;">document</span><span style="color: Gray;">.</span><span style="color: Blue;">createElement</span><span style="color: Olive;">(</span><span style="color: #8b0000;">'</span><span style="color: Red;">input</span><span style="color: #8b0000;">'</span><span style="color: Olive;">)</span><span style="color: Gray;">;<br /></span><span style="color: Blue;">rdo</span><span style="color: Gray;">.</span><span style="color: Blue;">setAttribute</span><span style="color: Olive;">(</span><span style="color: #8b0000;">'</span><span style="color: Red;">type</span><span style="color: #8b0000;">'</span><span style="color: Gray;">,</span><span style="color: #8b0000;">'</span><span style="color: Red;">radio</span><span style="color: #8b0000;">'</span><span style="color: Olive;">)</span><span style="color: Gray;">;<br /></span><span style="color: Blue;">rdo</span><span style="color: Gray;">.</span><span style="color: Blue;">setAttribute</span><span style="color: Olive;">(</span><span style="color: #8b0000;">'</span><span style="color: Red;">name</span><span style="color: #8b0000;">'</span><span style="color: Gray;">,</span><span style="color: #8b0000;">'</span><span style="color: Red;">radiobtn</span><span style="color: #8b0000;">'</span><span style="color: Olive;">)</span><span style="color: Gray;">;<br /></span><span style="color: Blue;">rdo</span><span style="color: Gray;">.</span><span style="color: Blue;">setAttribute</span><span style="color: Olive;">(</span><span style="color: #8b0000;">'</span><span style="color: Red;">value</span><span style="color: #8b0000;">'</span><span style="color: Gray;">,</span><span style="color: #8b0000;">'</span><span style="color: Red;">checked</span><span style="color: #8b0000;">'</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></div></div>
<p>IE:</p>
<div class="hl-surround"><div class="hl-main"><span style="color: Green;">var</span><span style="color: Gray;"> </span><span style="color: Blue;">rdo</span><span style="color: Gray;"> =</span><span style="color: Teal;">document</span><span style="color: Gray;">.</span><span style="color: Blue;">createElement</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">&lt;input type='radio' name='radiobtn' value='checked'&gt;</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">;</span></div></div>
<p>解决办法：<br />
这一点区别和前面的都不一样。这次完全不同，所以找不到共同的办法来解决，那么只有IF-ELSE了<br />
万幸的是，IE可以识别出document的uniqueID属性，别的浏览器都不可以识别出这一属性。问题解决。</p>
<p>0：共同的一些技巧<br />
在动态建立INPUT型输入元素时，一般是先加入，在设置TYPE。这就有可能出错</p>
<p>好习惯：<code>var btn = document.createElement('input');<br />
btn.setAttribut('type','button');<br />
document.getElementById('formId').appendChild(btn);</code></p>
<p>来源于：http://blog.csdn.net/zqian1987/archive/2008/03/02/2140055.aspx</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="能支持IE6的前端更牛，还是敢对IE6说不的更牛？" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fie6-must-die.html&from=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Ffirefox-and-ie-javascript.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/04/22/6197236.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">能支持IE6的前端更牛，还是敢对IE6说不的更牛？</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="IE6因为编码问题无法正确解析CSS文件" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fie6-css-zhusi.html&from=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Ffirefox-and-ie-javascript.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">IE6因为编码问题无法正确解析CSS文件</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="CSS样式中class和id的区别和含义" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fstyleforcssandidequbie.html&from=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Ffirefox-and-ie-javascript.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">CSS样式中class和id的区别和含义</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="最佳网页IE浏览器兼容性测试工具(IE6 IE7 IE8共存)" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fietester.html&from=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Ffirefox-and-ie-javascript.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/04/22/6199374.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">最佳网页IE浏览器兼容性测试工具(IE6 IE7 IE8共存)</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="IE下中英文字体不能对齐原因及解决" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fiexiazywbunenduiji.html&from=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Ffirefox-and-ie-javascript.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">IE下中英文字体不能对齐原因及解决</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table><h3  class="related_post_title">相关文章</h3><ul class="related_post"><li>2009-06-03 -- <a href="http://leotheme.cn/javascript/css-auto-for-br.html" title="CSS实现自动换行的小技巧">CSS实现自动换行的小技巧</a> (4)<br /><small>大家都知道连续的英文或数字能是容器被撑大，不能根据容器的大小自动换行，下面是 CSS如何将他们换行的方法！

对于div

1.（IE浏览器）white-space:normal; word-...</small></li><li>2009-08-30 -- <a href="http://leotheme.cn/javascript/css-3-0-chm.html" title="CSS 3.0 参考手册 (中文版)">CSS 3.0 参考手册 (中文版)</a> (9)<br /><small>作为一个Web开发者，保持对未来Web标准的关注、学习和了解是很重要的。不管你是第一次准备去认识CSS3，还是已经略知皮毛，这个来自腾讯的webteam发布的CSS 3.0 参考手册 (中文版)将有助...</small></li><li>2009-07-24 -- <a href="http://leotheme.cn/javascript/ie6-must-die.html" title="能支持IE6的前端更牛，还是敢对IE6说不的更牛？">能支持IE6的前端更牛，还是敢对IE6说不的更牛？</a> (27)<br /><small>作为一个前端，是能够支持更多的浏览器比较牛，还是勇于对IE6说不，更牛一些呢？IE6在其特定历史时期内起到了举足轻重的作用。而如今，是时候让他寿终正寝，离开历史舞台的时候了，他却欲罢还休不离不弃。面对...</small></li><li>2009-06-11 -- <a href="http://leotheme.cn/javascript/jquery-tab.html" title="jQuery 实现 tab 切换一例">jQuery 实现 tab 切换一例</a> (11)<br /><small>对于Tab切换，我想大家都不陌生了。现在几乎是到处可见了；今天为大家介绍下怎么用jQuery来实现一个简单的Tab切换效果。其实这类例子网上也有很多了，在这里不讨论它的实现原理，因为都是些最基本的应用...</small></li><li>2009-05-27 -- <a href="http://leotheme.cn/javascript/jquery-xingnen-youhua.html" title="jQuery性能优化指南">jQuery性能优化指南</a> (6)<br /><small>现在jquery应用的越来越多, 有些同学在享受爽快淋漓coding时就将性能问题忽略了,  比如我.  jquery虽在诸多的js类库中性能表现还算优秀, 但毕竟不是在用原生的javascript开...</small></li></ul>]]></content:encoded>
			<wfw:commentRss>http://leotheme.cn/javascript/firefox-and-ie-javascript.html/feed</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>CSS实现自动换行的小技巧</title>
		<link>http://leotheme.cn/javascript/css-auto-for-br.html</link>
		<comments>http://leotheme.cn/javascript/css-auto-for-br.html#comments</comments>
		<pubDate>Wed, 03 Jun 2009 06:12:07 +0000</pubDate>
		<dc:creator>Await</dc:creator>
				<category><![CDATA[前端交互]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[IE]]></category>
		<category><![CDATA[换行]]></category>

		<guid isPermaLink="false">http://leotheme.cn/?p=524</guid>
		<description><![CDATA[大家都知道连续的英文或数字能是容器被撑大，不能根据容器的大小自动换行，下面是 CSS如何将他们换行的方法！ 对于div 1.（IE浏览器）white-space:normal; word-break:break-all;这里前者是遵循标准。 #wrap{white-space:normal; width:200px; }或者#wrap{word-break:break-all;width:200px;}&#60;div id=&#34;wrap&#34;&#62;ddd111111111111111111111111111111&#60;/div&#62; 效果：可以实现换行 2.（Firefox浏览器）white-space:normal; word-break:break-all;overflow:hidden;同样的FF下也没有很好的实现方法，只能隐藏或者加滚动条，当然不加滚动条效果更好！ #wrap{white-space:normal; width:200px; overflow:auto;}或者#wrap{word-break:break-all;width:200px; overflow:auto; } &#60;div id=&#34;wrap&#34;&#62;ddd1111111111111111111111111111111111111111&#60;/div&#62; 效果：容器正常，内容隐藏 对于table 1. (IE浏览器)使用样式table-layout:fixed； &#60;style&#62;.tb{table-layout:fixed}&#60;/style&#62;&#60;table class=&#34;tbl&#34; width=&#34;80&#34;&#62;&#60;tr&#62;&#60;td&#62;abcdefghigklmnopqrstuvwxyz 1234567890&#60;/td&#62;&#60;/tr&#62;&#60;/table&#62; 效果：可以换行 2.(IE浏览器)使用样式 &#60;style&#62;.tb {table-layout:fixed}&#60;/style&#62;&#60;table class=&#34;tb&#34; width=&#34;80&#34;&#62;&#60;tr&#62;&#60;td nowrap&#62;abcdefghigklmnopqrstuvwxyz 1234567890&#60;/td&#62;&#60;/tr&#62;&#60;/table&#62; 效果：可以换行 3. (IE浏览器)在使用百分比固定td大小情况下使用样式table-layout:fixed与nowrap &#60;style&#62;.tb{table-layout:fixed}&#60;/style&#62;&#60;table class=&#34;tb&#34; width=80&#62;&#60;tr&#62;&#60;td width=25% nowrap&#62;abcdefghigklmnopqrstuvwxyz 1234567890&#60;/td&#62;&#60;td nowrap&#62;abcdefghigklmnopqrstuvwxyz 1234567890&#60;/td&#62;&#60;/tr&#62;&#60;/table&#62; 效果：两个td均正常换行 4.(Firefox浏览器)在使用百分比固定td大小情况下使用样式table-layout:fixed与nowrap,并且使用div &#60;style&#62;.tb {table-layout:fixed}.td {overflow:hidden;}&#60;/style&#62;&#60;table class=tb width=80&#62;&#60;tr&#62;&#60;td width=25% class=td [...]<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="使用lesscss来编码编写css" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fuse-lesscss-edit-css.html&from=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fcss-auto-for-br.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/09/24/33763230.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">使用lesscss来编码编写css</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="CSS中关于背景图的应用技巧" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fabout-css-background.html&from=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fcss-auto-for-br.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/04/22/6199351.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">CSS中关于背景图的应用技巧</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="CSS 3.0 参考手册 (中文版)" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fcss-3-0-chm.html&from=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fcss-auto-for-br.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/04/22/6197221.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">CSS 3.0 参考手册 (中文版)</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="IE6因为编码问题无法正确解析CSS文件" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fie6-css-zhusi.html&from=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fcss-auto-for-br.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">IE6因为编码问题无法正确解析CSS文件</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="CSS清除浮动的一些方法" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fcss-clear-float-fangfa.html&from=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fcss-auto-for-br.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">CSS清除浮动的一些方法</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>大家都知道连续的英文或数字能是容器被撑大，不能根据容器的大小自动换行，下面是 CSS如何将他们换行的方法！</p>
<p><strong>对于div</strong></p>
<p>1.（IE浏览器）white-space:normal; word-break:break-all;这里前者是遵循标准。</p>
<p><span id="more-524"></span></p>
<div class="hl-surround"><div class="hl-main"><span style="color: Gray;">#wrap{white-space:normal; width:200px; }<br />或者<br />#wrap{word-break:break-all;width:200px;}<br /></span><span style="color: Olive;">&lt;</span><span style="color: Green;">div</span><span style="color: Gray;"> </span><span style="color: #00008b;">id</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">wrap</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">&gt;</span><span style="color: Gray;">ddd111111111111111111111111111111</span><span style="color: Olive;">&lt;/</span><span style="color: Green;">div</span><span style="color: Olive;">&gt;</span></div></div>
<p>效果：可以实现换行</p>
<p>2.（Firefox浏览器）white-space:normal; word-break:break-all;overflow:hidden;同样的FF下也没有很好的实现方法，只能隐藏或者加滚动条，当然不加滚动条效果更好！</p>
<div class="hl-surround"><div class="hl-main"><span style="color: Gray;">#wrap{white-space:normal; width:200px; overflow:auto;}<br />或者<br />#wrap{word-break:break-all;width:200px; overflow:auto; } <br /></span><span style="color: Olive;">&lt;</span><span style="color: Green;">div</span><span style="color: Gray;"> </span><span style="color: #00008b;">id</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">wrap</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">&gt;</span><span style="color: Gray;">ddd1111111111111111111111111111111111111111</span><span style="color: Olive;">&lt;/</span><span style="color: Green;">div</span><span style="color: Olive;">&gt;</span></div></div>
<p>效果：容器正常，内容隐藏</p>
<p><strong>对于table</strong></p>
<p>1. (IE浏览器)使用样式table-layout:fixed；</p>
<div class="hl-surround"><div class="hl-main"><span style="color: Olive;">&lt;</span><span style="color: Green;">style</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br />.tb{table-layout:fixed}<br /></span><span style="color: Olive;">&lt;/</span><span style="color: Green;">style</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br /></span><span style="color: Olive;">&lt;</span><span style="color: Green;">table</span><span style="color: Gray;"> </span><span style="color: #00008b;">class</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">tbl</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">width</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">80</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br /></span><span style="color: Olive;">&lt;</span><span style="color: Green;">tr</span><span style="color: Olive;">&gt;&lt;</span><span style="color: Green;">td</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br />abcdefghigklmnopqrstuvwxyz 1234567890<br /></span><span style="color: Olive;">&lt;/</span><span style="color: Green;">td</span><span style="color: Olive;">&gt;&lt;/</span><span style="color: Green;">tr</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br /></span><span style="color: Olive;">&lt;/</span><span style="color: Green;">table</span><span style="color: Olive;">&gt;</span></div></div>
<p>效果：可以换行</p>
<p>2.(IE浏览器)使用样式</p>
<div class="hl-surround"><div class="hl-main"><span style="color: Olive;">&lt;</span><span style="color: Green;">style</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br />.tb {table-layout:fixed}<br /></span><span style="color: Olive;">&lt;/</span><span style="color: Green;">style</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br /></span><span style="color: Olive;">&lt;</span><span style="color: Green;">table</span><span style="color: Gray;"> </span><span style="color: #00008b;">class</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">tb</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">width</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">80</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">&gt;&lt;</span><span style="color: Green;">tr</span><span style="color: Olive;">&gt;&lt;</span><span style="color: Green;">td</span><span style="color: Gray;"> </span><span style="color: #00008b;">nowrap</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br />abcdefghigklmnopqrstuvwxyz 1234567890<br /></span><span style="color: Olive;">&lt;/</span><span style="color: Green;">td</span><span style="color: Olive;">&gt;&lt;/</span><span style="color: Green;">tr</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br /></span><span style="color: Olive;">&lt;/</span><span style="color: Green;">table</span><span style="color: Olive;">&gt;</span></div></div>
<p>效果：可以换行</p>
<p>3. (IE浏览器)在使用百分比固定td大小情况下使用样式table-layout:fixed与nowrap</p>
<div class="hl-surround"><div class="hl-main"><span style="color: Olive;">&lt;</span><span style="color: Green;">style</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br />.tb{table-layout:fixed}<br /></span><span style="color: Olive;">&lt;/</span><span style="color: Green;">style</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br /></span><span style="color: Olive;">&lt;</span><span style="color: Green;">table</span><span style="color: Gray;"> </span><span style="color: #00008b;">class</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">tb</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">width</span><span style="color: Gray;">=</span><span style="color: #00008b;">80</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br /></span><span style="color: Olive;">&lt;</span><span style="color: Green;">tr</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br /></span><span style="color: Olive;">&lt;</span><span style="color: Green;">td</span><span style="color: Gray;"> </span><span style="color: #00008b;">width</span><span style="color: Gray;">=</span><span style="color: #00008b;">25</span><span style="color: Gray;">% </span><span style="color: #00008b;">nowrap</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br />abcdefghigklmnopqrstuvwxyz 1234567890<br /></span><span style="color: Olive;">&lt;/</span><span style="color: Green;">td</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br /></span><span style="color: Olive;">&lt;</span><span style="color: Green;">td</span><span style="color: Gray;"> </span><span style="color: #00008b;">nowrap</span><span style="color: Olive;">&gt;</span><span style="color: Gray;">abcdefghigklmnopqrstuvwxyz 1234567890</span><span style="color: Olive;">&lt;/</span><span style="color: Green;">td</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br /></span><span style="color: Olive;">&lt;/</span><span style="color: Green;">tr</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br /></span><span style="color: Olive;">&lt;/</span><span style="color: Green;">table</span><span style="color: Olive;">&gt;</span></div></div>
<p>效果：两个td均正常换行</p>
<p>4.(Firefox浏览器)在使用百分比固定td大小情况下使用样式table-layout:fixed与nowrap,并且使用div</p>
<div class="hl-surround"><div class="hl-main"><span style="color: Olive;">&lt;</span><span style="color: Green;">style</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br />.tb {table-layout:fixed}<br />.td {overflow:hidden;}<br /></span><span style="color: Olive;">&lt;/</span><span style="color: Green;">style</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br /></span><span style="color: Olive;">&lt;</span><span style="color: Green;">table</span><span style="color: Gray;"> </span><span style="color: #00008b;">class</span><span style="color: Gray;">=</span><span style="color: #00008b;">tb</span><span style="color: Gray;"> </span><span style="color: #00008b;">width</span><span style="color: Gray;">=</span><span style="color: #00008b;">80</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br /></span><span style="color: Olive;">&lt;</span><span style="color: Green;">tr</span><span style="color: Olive;">&gt;&lt;</span><span style="color: Green;">td</span><span style="color: Gray;"> </span><span style="color: #00008b;">width</span><span style="color: Gray;">=</span><span style="color: #00008b;">25</span><span style="color: Gray;">% </span><span style="color: #00008b;">class</span><span style="color: Gray;">=</span><span style="color: #00008b;">td</span><span style="color: Gray;"> </span><span style="color: #00008b;">nowrap</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br /></span><span style="color: Olive;">&lt;</span><span style="color: Green;">div</span><span style="color: Olive;">&gt;</span><span style="color: Gray;">abcdefghigklmnopqrstuvwxyz 1234567890</span><span style="color: Olive;">&lt;/</span><span style="color: Green;">div</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br /></span><span style="color: Olive;">&lt;/</span><span style="color: Green;">td</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br /></span><span style="color: Olive;">&lt;</span><span style="color: Green;">td</span><span style="color: Gray;"> </span><span style="color: #00008b;">class</span><span style="color: Gray;">=</span><span style="color: #00008b;">td</span><span style="color: Gray;"> </span><span style="color: #00008b;">nowrap</span><span style="color: Olive;">&gt;&lt;</span><span style="color: Green;">div</span><span style="color: Olive;">&gt;</span><span style="color: Gray;">abcdefghigklmnopqrstuvwxyz 1234567890</span><span style="color: Olive;">&lt;/</span><span style="color: Green;">div</span><span style="color: Olive;">&gt;&lt;/</span><span style="color: Green;">td</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br /></span><span style="color: Olive;">&lt;/</span><span style="color: Green;">tr</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br /></span><span style="color: Olive;">&lt;/</span><span style="color: Green;">table</span><span style="color: Olive;">&gt;</span></div></div>
<p>这里单元格宽度一定要用百分比定义 效果：正常显示，但不能换行。</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="使用lesscss来编码编写css" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fuse-lesscss-edit-css.html&from=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fcss-auto-for-br.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/09/24/33763230.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">使用lesscss来编码编写css</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="CSS中关于背景图的应用技巧" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fabout-css-background.html&from=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fcss-auto-for-br.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/04/22/6199351.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">CSS中关于背景图的应用技巧</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="CSS 3.0 参考手册 (中文版)" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fcss-3-0-chm.html&from=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fcss-auto-for-br.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/04/22/6197221.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">CSS 3.0 参考手册 (中文版)</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="IE6因为编码问题无法正确解析CSS文件" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fie6-css-zhusi.html&from=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fcss-auto-for-br.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">IE6因为编码问题无法正确解析CSS文件</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="CSS清除浮动的一些方法" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fcss-clear-float-fangfa.html&from=http%3A%2F%2Fleotheme.cn%2Fjavascript%2Fcss-auto-for-br.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">CSS清除浮动的一些方法</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table><h3  class="related_post_title">相关文章</h3><ul class="related_post"><li>2010-08-10 -- <a href="http://leotheme.cn/javascript/firefox-and-ie-javascript.html" title="firefox与ie 的javascript区别">firefox与ie 的javascript区别</a> (19)<br /><small>浏览器的兼容问题目前还是一个头痛的问题。除了CSS的兼容性，Javascript的兼容有时候更容易让人头痛。下面收集的一些关于Firefox和IE的区别作个记号，需要的时候看看

1. Docum...</small></li><li>2011-09-24 -- <a href="http://leotheme.cn/javascript/use-lesscss-edit-css.html" title="使用lesscss来编码编写css">使用lesscss来编码编写css</a> (12)<br /><small>lesscss 是动态的样式表语言，他让css增加变量，组合，函数，运算等语法。这个项目的网站在国内访问不到，大家都懂的。

lesscss使用方法有两种：

页面添加一个 less.js的文...</small></li><li>2009-11-11 -- <a href="http://leotheme.cn/javascript/css-to-realize-accordant.html" title="左右两栏等高实现方法">左右两栏等高实现方法</a> (6)<br /><small>等高布局在实际的应用中会经常用到。最常见的是左边的内容很多。而右边的内容却很少。为了不让右边出现太多的空白，有时需要让右边的高度和左边的保持一致。实现的方法有很多，以前一般是用背景填充来模拟。虽然很简...</small></li><li>2009-08-30 -- <a href="http://leotheme.cn/javascript/css-3-0-chm.html" title="CSS 3.0 参考手册 (中文版)">CSS 3.0 参考手册 (中文版)</a> (9)<br /><small>作为一个Web开发者，保持对未来Web标准的关注、学习和了解是很重要的。不管你是第一次准备去认识CSS3，还是已经略知皮毛，这个来自腾讯的webteam发布的CSS 3.0 参考手册 (中文版)将有助...</small></li><li>2009-07-07 -- <a href="http://leotheme.cn/javascript/nuheshienide-css-gengyiyuedui.html" title="如何使你的CSS样式更易阅读?">如何使你的CSS样式更易阅读?</a> (15)<br /><small>在做wordpress主题的时候，样式是最重要的一部分。作为主题的制作者，我们不但要考滤页面的还原完整度，还要一个重要的就是要让CSS阅读起来很容易。因为不管我们怎么尽力去做到完美，但每个人都想主题更...</small></li></ul>]]></content:encoded>
			<wfw:commentRss>http://leotheme.cn/javascript/css-auto-for-br.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

