document.write各浏览器差异

日期:2011-08-06    阅读:54   分类:Javascript


相信document.write大家都使用过,不知道大家是否发现,其实不同浏览器在某些时候还是有差异的,看如下代码:

/**
*@load the cnzz analytics
*/
document.write("<div id='cvb'><scr"+"ipt src='http://s13.cnzz.com/stat.php?id=***&web_id=***&show=pic' type='text/javascript'></scr"+"ipt></div>");

上面代码在输出的 <script>里又再次调用了 document.write ,假设输出的是html代码,那么通过观察会发现:

1. IE9 - 第二次document.write出来的东西会脱离id为cvb的div
2. Firefox, google chrome, safari这些浏览器会将嵌套document.write输出的东西正确的放到其父节点里面。

因此这个东西在嵌套输出的时候还是得慎用。

本页链接: http://www.scriptlover.com/static/797-document-write-浏览器

标签:

相关文章

网友评论

Leave a comment

 required

 required (Not published)

 required