javascript输出问题

来源:百度知道 编辑:UC知道 时间:2024/06/07 11:56:11
最近用js来调用页脚,我在js文件中用document.write('html代码'),没问题,可是后来想调用一个雅虎统计,可是雅虎统计本身就是JS文件,也用了document.write('统计代码'),这样当然出错,不知道怎么解决,难道不能在js里输出js文件的内容吗?
参考统计代码:<script type="text/javascript" src="http://js.tongji.yahoo.com.cn/1/419/500/ystat.js"></script><noscript><a href="http://js.tongji.yahoo.com.cn"><img src=http://js.tongji.yahoo.com.cn/1/419/500/ystat.gif border="0"></a></noscript><script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "

当然可以,只是要处理一下(下面的所有代码都要写在一行上,拷贝的时候要注意):

document.write('<script type="text/javascript" src="
http://js.tongji.yahoo.com.cn/1/419/500/ystat.js"><\/\script><noscript><a href="http://js.tongji.yahoo.com.cn"><img src=http://js.tongji.yahoo.com.cn/1/419/500/ystat.gif border="0"></a></noscript><script type="text/javascript"> var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("