<?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; javascript笔记</title>
	<atom:link href="http://www.stadin.info/category/javascript/feed" rel="self" type="application/rss+xml" />
	<link>http://www.stadin.info</link>
	<description>city vagrant</description>
	<lastBuildDate>Thu, 20 Oct 2011 08:26:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Date对象的getYear和getFullYear方法</title>
		<link>http://www.stadin.info/643.html</link>
		<comments>http://www.stadin.info/643.html#comments</comments>
		<pubDate>Tue, 10 Feb 2009 09:58:31 +0000</pubDate>
		<dc:creator>城市过客甲</dc:creator>
				<category><![CDATA[javascript笔记]]></category>

		<guid isPermaLink="false">http://www.stadin.info/?p=643</guid>
		<description><![CDATA[在JavaScript中，Date对象获得年份有getYear和getFullYear两种方法 经测试 var d=new Date; alert(d.getYear())在IE中返回2009，在Firefox中会返回109。经查询手册，getYear在Firefox下返回的是距1900年1月1日的年份，这是一个过时而不被推荐的方法。 而alert(d.getFullYear())在IE和FF中都会返回2009。因此，无论何时都应使用getFullYear来替代getYear方法。]]></description>
			<content:encoded><![CDATA[<p>在JavaScript中，Date对象获得年份有getYear和getFullYear两种方法<br />
经测试<br />
var d=new Date;<br />
alert(d.getYear())在IE中返回2009，在Firefox中会返回109。经查询手册，getYear在Firefox下返回的是距1900年1月1日的年份，这是一个过时而不被推荐的方法。<br />
而alert(d.getFullYear())在IE和FF中都会返回2009。因此，无论何时都应使用getFullYear来替代getYear方法。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.stadin.info/643.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>IE的一个中止页面打开操作bug</title>
		<link>http://www.stadin.info/247.html</link>
		<comments>http://www.stadin.info/247.html#comments</comments>
		<pubDate>Sat, 14 Jun 2008 03:42:17 +0000</pubDate>
		<dc:creator>城市过客甲</dc:creator>
				<category><![CDATA[javascript笔记]]></category>
		<category><![CDATA[appendChild]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[IE]]></category>

		<guid isPermaLink="false">http://www.stadin.info/?p=247</guid>
		<description><![CDATA[据我所知，如果有js在页面没有完全加载完成时，执行document.body.appendChild方法会出错导致页面全部被清除，不能正常显示，insertBefore是不被建议使用的。 其中的一种解决办法如此博文所示，将document.body.appendChild(jsNode)改为document.getElementsByTagName(&#8216;head&#8217;)[0].appendChild(jsNode) 即把对body的appendChild操作改成对HEAD区进行 引用：http://hi.baidu.com/webria/blog/item/5aef441196ffc413b9127ba3.html 另外，仍有可能出现这个状况的时候，就只能写window.onload=function&#8230;]]></description>
			<content:encoded><![CDATA[<p>据我所知，如果有js在页面没有完全加载完成时，执行document.body.appendChild方法会出错导致页面全部被清除，不能正常显示，insertBefore是不被建议使用的。</p>
<p>其中的一种解决办法如此博文所示，将document.body.appendChild(jsNode)改为document.getElementsByTagName(&#8216;head&#8217;)[0].appendChild(jsNode)</p>
<p>即把对body的appendChild操作改成对HEAD区进行</p>
<p>引用：<a href="http://hi.baidu.com/webria/blog/item/5aef441196ffc413b9127ba3.html">http://hi.baidu.com/webria/blog/item/5aef441196ffc413b9127ba3.html</a></p>
<p>另外，仍有可能出现这个状况的时候，就只能写window.onload=function&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.stadin.info/247.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>实现不跨顶级域名的跨域</title>
		<link>http://www.stadin.info/131.html</link>
		<comments>http://www.stadin.info/131.html#comments</comments>
		<pubDate>Wed, 29 Aug 2007 07:46:45 +0000</pubDate>
		<dc:creator>城市过客甲</dc:creator>
				<category><![CDATA[javascript笔记]]></category>

		<guid isPermaLink="false">http://www.stadin.info/131.html</guid>
		<description><![CDATA[将这个问题举例以更容易理解  如果想在www.stadin.info， 使用window.open方法打开test.stadin.info，如何在test.stadin.info取得window.opener.location 只要在两边的开头都写上document.domain=”stadin.info”; 浏览器就会认为两边没有跨域的问题。如果打开一个非stadin.info结尾的网站，并试图跨域回来，那就没有这么简单的方法了。]]></description>
			<content:encoded><![CDATA[<p>将这个问题举例以更容易理解 </p>
<p>如果想在<a href="http://www.stadin.info/">www.stadin.info</a>，</p>
<p>使用window.open方法打开test.stadin.info，如何在test.stadin.info取得window.opener.location</p>
<p>只要在两边的开头都写上document.domain=”stadin.info”;</p>
<p>浏览器就会认为两边没有跨域的问题。如果打开一个非stadin.info结尾的网站，并试图跨域回来，那就没有这么简单的方法了。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.stadin.info/131.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>firstChild.nodeValue</title>
		<link>http://www.stadin.info/76.html</link>
		<comments>http://www.stadin.info/76.html#comments</comments>
		<pubDate>Tue, 27 Mar 2007 00:34:18 +0000</pubDate>
		<dc:creator>城市过客甲</dc:creator>
				<category><![CDATA[javascript笔记]]></category>

		<guid isPermaLink="false">http://www.stadin.info/?p=76</guid>
		<description><![CDATA[假设我们已经有一个dom对象，其内容如 内容 在javascript中，我们为了获得title的标签和文本，一般需要这样做 var title =dom.getElementsByTagName(“title”); alert(title[0].nodeName);//得到“title” alert(title[0].nodeValue)的时候，FF只能获得#text，而IE只能得到null 后来查了很多资料，object text类型或者object element，本身也是一个结点 上例中“标题”不是一个简单的文本内容，而是一个文本结点 它也有自己的nodeName，只是不该也不会用到 所以应该写成： alert(title[0].firstChild.nodeValue);//得到“标题” 另一方面，反过来想，生成一个文本的时候，也是用create_text_node方法 还使用了append_child把它添加在一个父结点下 说明它其实是一个结点，需要多使用一次firstChild]]></description>
			<content:encoded><![CDATA[<p>假设我们已经有一个dom对象，其内容如<br />
内容</p>
<p>在javascript中，我们为了获得title的标签和文本，一般需要这样做<br />
var title =dom.getElementsByTagName(“title”);<br />
alert(title[0].nodeName);//得到“title”<br />
alert(title[0].nodeValue)的时候，FF只能获得#text，而IE只能得到null<br />
后来查了很多资料，object text类型或者object element，本身也是一个结点<br />
上例中“标题”不是一个简单的文本内容，而是一个文本结点<br />
它也有自己的nodeName，只是不该也不会用到<br />
所以应该写成：<br />
alert(title[0].firstChild.nodeValue);//得到“标题”</p>
<p>另一方面，反过来想，生成一个文本的时候，也是用create_text_node方法<br />
还使用了append_child把它添加在一个父结点下<br />
说明它其实是一个结点，需要多使用一次firstChild</p>
]]></content:encoded>
			<wfw:commentRss>http://www.stadin.info/76.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CSS中expression的使用</title>
		<link>http://www.stadin.info/60.html</link>
		<comments>http://www.stadin.info/60.html#comments</comments>
		<pubDate>Wed, 14 Feb 2007 03:42:54 +0000</pubDate>
		<dc:creator>城市过客甲</dc:creator>
				<category><![CDATA[javascript笔记]]></category>

		<guid isPermaLink="false">http://www.stadin.info/?p=60</guid>
		<description><![CDATA[先来看一个例子  它表示，在td上如果发生onmouseover或onmouseout事件，则执行expression给出的函数，不必在每个td上再写onmouseover和onmouseout了。]]></description>
			<content:encoded><![CDATA[<p>先来看一个例子 </p>
<style>
td
{
  /*设置onmouseover事件*/
  onmouseover: expression(onmouseover=function (){this.style.borderColor ='blue';this.style.color='red';this.style.backgroundColor ='yellow'});</p>
<p>  /*设置onmouseout事件*/
  onmouseout: expression(onmouseout=function (){this.style.borderColor='';this.style.color='';this.style.backgroundColor =''});
  background-color:#ffffff;
}
</style>
<p>它表示，在td上如果发生onmouseover或onmouseout事件，则执行expression给出的函数，不必在每个td上再写onmouseover和onmouseout了。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.stadin.info/60.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>将页面表格直接存成xls文件</title>
		<link>http://www.stadin.info/57.html</link>
		<comments>http://www.stadin.info/57.html#comments</comments>
		<pubDate>Mon, 15 Jan 2007 03:19:28 +0000</pubDate>
		<dc:creator>城市过客甲</dc:creator>
				<category><![CDATA[javascript笔记]]></category>

		<guid isPermaLink="false">http://www.stadin.info/?p=57</guid>
		<description><![CDATA[其实就是保存整个表格，也可以用这个方法保存连续若干拼起来的HTML代码 点击看看：保存整个表格 补充：这个execCommand方法的SaveAs命令在IE7下不被支持……无语]]></description>
			<content:encoded><![CDATA[<p>其实就是保存整个表格，也可以用这个方法保存连续若干拼起来的HTML代码</p>
<p>点击看看：<a id="p56" href="http://www.stadin.info/wp-content/uploads/2007/01/tablebase.htm" target="_blank">保存整个表格</a></p>
<p>补充：这个execCommand方法的SaveAs命令在IE7下不被支持……无语</p>
]]></content:encoded>
			<wfw:commentRss>http://www.stadin.info/57.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>javascript的几则经验</title>
		<link>http://www.stadin.info/53.html</link>
		<comments>http://www.stadin.info/53.html#comments</comments>
		<pubDate>Sat, 30 Dec 2006 02:34:53 +0000</pubDate>
		<dc:creator>城市过客甲</dc:creator>
				<category><![CDATA[javascript笔记]]></category>

		<guid isPermaLink="false">http://www.stadin.info/?p=53</guid>
		<description><![CDATA[用window.close()不出现提示“是否关闭本页面”的方法： 在页面最开始的javascript写上window.opener=this; 页面如果不是用window.open方法打开的，window.close就会提示，在页面最开始写上这句话，骗浏览器说是用window.open打开的，就可以顺利关闭了。 onblur（失去焦点）时根据点击的对象做不同的操作 document.activeElement即为点击的对象，我用了document.activeElement.id，也就是该对象的ID来判断点击的是保存还是取消，在点击取消时不做任何判断操作。 获得鼠标点击位置离表格边框（左边框）的水平距离 没法直接得到，先取得event.x，即鼠标点击位置离页面边框的水平距离 用以下函数获得这个表格到页面边框的水平距离，相减得到鼠标点击位置到表格左边框的水平距离 function posX(d){ var s_el=0; el=d; while(el){ s_el=s_el+el.offsetLeft; el=el.offsetParent;} return s_el};]]></description>
			<content:encoded><![CDATA[<p>用window.close()不出现提示“是否关闭本页面”的方法：</p>
<p>在页面最开始的javascript写上window.opener=this;<br />
页面如果不是用window.open方法打开的，window.close就会提示，在页面最开始写上这句话，骗浏览器说是用window.open打开的，就可以顺利关闭了。</p>
<p>onblur（失去焦点）时根据点击的对象做不同的操作</p>
<p>document.activeElement即为点击的对象，我用了document.activeElement.id，也就是该对象的ID来判断点击的是保存还是取消，在点击取消时不做任何判断操作。</p>
<p>获得鼠标点击位置离表格边框（左边框）的水平距离</p>
<p>没法直接得到，先取得event.x，即鼠标点击位置离页面边框的水平距离<br />
用以下函数获得这个表格到页面边框的水平距离，相减得到鼠标点击位置到表格左边框的水平距离<br />
function posX(d){<br />
var s_el=0;<br />
el=d;<br />
while(el){<br />
s_el=s_el+el.offsetLeft;<br />
el=el.offsetParent;}<br />
return s_el};</p>
]]></content:encoded>
			<wfw:commentRss>http://www.stadin.info/53.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>scrollLeft,scrollWidth,clientWidth,offsetWidth</title>
		<link>http://www.stadin.info/49.html</link>
		<comments>http://www.stadin.info/49.html#comments</comments>
		<pubDate>Thu, 14 Dec 2006 05:35:02 +0000</pubDate>
		<dc:creator>城市过客甲</dc:creator>
				<category><![CDATA[javascript笔记]]></category>

		<guid isPermaLink="false">http://www.stadin.info/?p=49</guid>
		<description><![CDATA[  补充： scrollHeight: 获取对象的滚动高度。 scrollLeft:设置或获取位于对象左边界和窗口中目前可见内容的最左端之间的距离 scrollTop:设置或获取位于对象最顶端和窗口中可见内容的最顶端之间的距离 scrollWidth:获取对象的滚动宽度 offsetHeight:获取对象相对于版面或由父坐标 offsetParent 属性指定的父坐标的高度 offsetLeft:获取对象相对于版面或由 offsetParent 属性指定的父坐标的计算左侧位置 offsetTop:获取对象相对于版面或由 offsetTop 属性指定的父坐标的计算顶端位置 event.clientX 相对文档的水平座标event.clientY 相对文档的垂直座标 event.offsetX 相对容器的水平坐标event.offsetY 相对容器的垂直坐标 document.documentElement.scrollTop 垂直方向滚动的值event.clientX+document.documentElement.scrollTop 相对文档的水平座标+垂直方向滚动的量]]></description>
			<content:encoded><![CDATA[<p><a class="imagelink" title="说明图" href="http://www.stadin.info/wp-content/uploads/2006/12/20061214.jpg"><img id="image48" height="96" alt="说明图" src="http://www.stadin.info/wp-content/uploads/2006/12/20061214.jpg" /></a> </p>
<p>补充：<br />
scrollHeight: 获取对象的滚动高度。<br />
scrollLeft:设置或获取位于对象左边界和窗口中目前可见内容的最左端之间的距离<br />
scrollTop:设置或获取位于对象最顶端和窗口中可见内容的最顶端之间的距离<br />
scrollWidth:获取对象的滚动宽度<br />
offsetHeight:获取对象相对于版面或由父坐标 offsetParent 属性指定的父坐标的高度<br />
offsetLeft:获取对象相对于版面或由 offsetParent 属性指定的父坐标的计算左侧位置<br />
offsetTop:获取对象相对于版面或由 offsetTop 属性指定的父坐标的计算顶端位置 event.clientX 相对文档的水平座标event.clientY 相对文档的垂直座标<br />
event.offsetX 相对容器的水平坐标event.offsetY 相对容器的垂直坐标 document.documentElement.scrollTop 垂直方向滚动的值event.clientX+document.documentElement.scrollTop 相对文档的水平座标+垂直方向滚动的量</p>
]]></content:encoded>
			<wfw:commentRss>http://www.stadin.info/49.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Javascript的IE和Firefox兼容性汇编 zz</title>
		<link>http://www.stadin.info/41.html</link>
		<comments>http://www.stadin.info/41.html#comments</comments>
		<pubDate>Wed, 08 Nov 2006 03:13:06 +0000</pubDate>
		<dc:creator>城市过客甲</dc:creator>
				<category><![CDATA[javascript笔记]]></category>

		<guid isPermaLink="false">http://www.stadin.info/?p=41</guid>
		<description><![CDATA[最近写了很多只有IE才支持的JS代码，看了下该文，获益匪浅 [保留] [学习]Javascript的IE和Firefox兼容性汇编 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; http://www.chinaunix.net 作者:HonestQiao 发表于：2006-02-23 09:53:27 【发表评论】【查看原文】【HTML/JavaScript讨论区】【关闭】 [学习]Javascript的IE和Firefox兼容性汇编 以下以 IE 代替 Internet Explorer，以 MF 代替 Mozzila Firefox 1. document.form.item 问题 (1)现有问题： 现有代码中存在许多 document.formName.item(“itemName”) 这样的语句，不能在 MF 下运行 (2)解决方法： 改用 document.formName.elements["elementName"] (3)其它 参见 2 2. 集合类对象问题 (1)现有问题： 现有代码中许多集合类对象取用时使用 ()，IE 能接受，MF 不能。 (2)解决方法： 改用 [] 作为下标运算。如：document.forms(“formName”) 改为 document.forms["formName"]。 又如：document.getElementsByName(“inputName”)(1) 改为 document.getElementsByName(“inputName”)[1] (3)其它 3. window.event (1)现有问题： 使用 [...]]]></description>
			<content:encoded><![CDATA[<p>最近写了很多只有IE才支持的JS代码，看了下该文，获益匪浅<br />
<span id="more-41"></span></p>
<p>[保留] [学习]Javascript的IE和Firefox兼容性汇编</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>http://www.chinaunix.net 作者:HonestQiao 发表于：2006-02-23 09:53:27<br />
【发表评论】【查看原文】【HTML/JavaScript讨论区】【关闭】</p>
<p>[学习]Javascript的IE和Firefox兼容性汇编<br />
以下以 IE 代替 Internet Explorer，以 MF 代替 Mozzila Firefox<br />
1. document.form.item 问题<br />
(1)现有问题：<br />
现有代码中存在许多 document.formName.item(“itemName”) 这样的语句，不能在 MF 下运行<br />
(2)解决方法：<br />
改用 document.formName.elements["elementName"]<br />
(3)其它<br />
参见 2<br />
2. 集合类对象问题<br />
(1)现有问题：<br />
现有代码中许多集合类对象取用时使用 ()，IE 能接受，MF 不能。<br />
(2)解决方法：<br />
改用 [] 作为下标运算。如：document.forms(“formName”) 改为 document.forms["formName"]。<br />
又如：document.getElementsByName(“inputName”)(1) 改为 document.getElementsByName(“inputName”)[1]<br />
(3)其它<br />
3. window.event<br />
(1)现有问题：<br />
使用 window.event 无法在 MF 上运行<br />
(2)解决方法：<br />
MF 的 event 只能在事件发生的现场使用，此问题暂无法解决。可以这样变通：<br />
原代码(可在IE中运行)：</p>
<input onclick="javascript:gotoSubmit()" type="button" name="someButton" value="提交" />
&#8230;<br />
<script language="javascript">
function gotoSubmit() {
...
alert(window.event); // use window.event
...
}
</script><br />
新代码(可在IE和MF中运行)：</p>
<input onclick="javascript:gotoSubmit(event)" type="button" name="someButton" value="提交" />
&#8230;<br />
<script language="javascript">
function gotoSubmit(evt) {
evt = evt ? evt : (window.event ? window.event : null);
...
alert(evt); // use evt
...
}
</script><br />
此外，如果新代码中第一行不改，与老代码一样的话(即 gotoSubmit 调用没有给参数)，则仍然只能在IE中运行，但不会出错。所以，这种方案 tpl 部分仍与老代码兼容。<br />
4. HTML 对象的 id 作为对象名的问题<br />
(1)现有问题<br />
在 IE 中，HTML 对象的 ID 可以作为 document 的下属对象变量名直接使用。在 MF 中不能。<br />
(2)解决方法<br />
用 getElementById(“idName”) 代替 idName 作为对象变量使用。<br />
5. 用idName字符串取得对象的问题<br />
(1)现有问题<br />
在IE中，利用 eval(idName) 可以取得 id 为 idName 的 HTML 对象，在MF 中不能。<br />
(2)解决方法<br />
用 getElementById(idName) 代替 eval(idName)。<br />
6. 变量名与某 HTML 对象 id 相同的问题<br />
(1)现有问题<br />
在 MF 中，因为对象 id 不作为 HTML 对象的名称，所以可以使用与 HTML 对象 id 相同的变量名，IE 中不能。<br />
(2)解决方法<br />
在声明变量时，一律加上 var ，以避免歧义，这样在 IE 中亦可正常运行。<br />
此外，最好不要取与 HTML 对象 id 相同的变量名，以减少错误。<br />
(3)其它<br />
参见 问题4<br />
7. event.x 与 event.y 问题<br />
(1)现有问题<br />
在IE 中，event 对象有 x, y 属性，MF中没有。<br />
(2)解决方法<br />
在MF中，与event.x 等效的是 event.pageX。但event.pageX IE中没有。<br />
故采用 event.clientX 代替 event.x。在IE 中也有这个变量。<br />
event.clientX 与 event.pageX 有微妙的差别（当整个页面有滚动条的时候），不过大多数时候是等效的。<br />
如果要完全一样，可以稍麻烦些：<br />
mX = event.x ? event.x : event.pageX;<br />
然后用 mX 代替 event.x<br />
(3)其它<br />
event.layerX 在 IE 与 MF 中都有，具体意义有无差别尚未试验。</p>
<p>8. 关于frame<br />
(1)现有问题<br />
在 IE中 可以用window.testFrame取得该frame，mf中不行<br />
(2)解决方法<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的内容<br />
关于frame和window的描述可以参见bbs的‘window与frame’文章<br />
以及/test/js/test_frame/目录下面的测试<br />
&#8212;-adun 2004.12.09修改<br />
9. 在mf中，自己定义的属性必须getAttribute()取得<br />
10.在mf中没有 parentElement parement.children 而用<br />
parentNode parentNode.childNodes<br />
childNodes的下标的含义在IE和MF中不同，MF使用DOM规范，childNodes中会插入空白文本节点。<br />
一般可以通过node.getElementsByTagName()来回避这个问题。<br />
当html中节点缺失时，IE和MF对parentNode的解释不同，例如</p>
<form>
<table>
<input type="text" />
<tbody /></table>
</form>
<p>MF中input.parentNode的值为form, 而IE中input.parentNode的值为空节点<br />
MF中节点没有removeNode方法，必须使用如下方法 node.parentNode.removeChild(node)<br />
11.const 问题<br />
(1)现有问题:<br />
在 IE 中不能使用 const 关键字。如 const constVar = 32; 在IE中这是语法错误。<br />
(2)解决方法:<br />
不使用 const ，以 var 代替。<br />
12. body 对象<br />
MF的body在body标签没有被浏览器完全读入之前就存在，而IE则必须在body完全被读入之后才存在<br />
13. url encoding<br />
在js中如果书写url就直接写&#038;不要写&#038;例如var url = &#8216;xx.jsp?objectName=xx&#038;objectEvent=xxx&#8217;;<br />
frm.action = url那么很有可能url不会被正常显示以至于参数没有正确的传到服务器<br />
一般会服务器报错参数没有找到<br />
当然如果是在tpl中例外，因为tpl中符合xml规范，要求&#038;书写为&#038;<br />
一般MF无法识别js中的&#038;</p>
<p>14. nodeName 和 tagName 问题<br />
(1)现有问题：<br />
在MF中，所有节点均有 nodeName 值，但 textNode 没有 tagName 值。在 IE 中，nodeName 的使用好象<br />
有问题（具体情况没有测试，但我的IE已经死了好几次）。<br />
(2)解决方法：<br />
使用 tagName，但应检测其是否为空。<br />
15. 元素属性<br />
IE下 input.type属性为只读，但是MF下可以修改</p>
<p>16. document.getElementsByName() 和 document.all[name] 的问题<br />
(1)现有问题：<br />
在 IE 中，getElementsByName()、document.all[name] 均不能用来取得 div 元素（是否还有其它不能取的元素还不知道）。</p>
<p>[color=#CCCCCC]转载自:http://afeng.open-src.com/viewarticle.php?id=84[/color]</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
HonestQiao 回复于：2005-12-09 09:38:40</p>
<p>1. 对象问题<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 />
document.getElementById(“itemId”)<br />
备注<br />
document.all是IE自定义的方法，所以请大家尽量不使用。<br />
还有一种方式，在IE和MF都可以使用<br />
var f = document.forms["formName "];<br />
var o = f. itemId;</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>
]]></content:encoded>
			<wfw:commentRss>http://www.stadin.info/41.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

