页面里同样的代码,为什么一个运行,一个不运行?
两个分享按钮代码如下,<div id="L1">是直接写入的,所有功能正常;<div id="L2">是document加载的,审查元素转义正确,和L1的代码相同,却不显示分享按钮:
<script type="text/javascript">var _ga2="全局变量_ga2"var sj="logo"</script><div id="L1"><script type="text/javascript"charset="utf-8">(function(){var _w=106,_h=24;var param={url:location.href,type:'5',count:'',appkey:'',title:_ga2+'…',pic:'http://csdnimg.cn/www/images/csdnindex_'+sj+'.gif',ralateUid:'',language:'zh_cn',rnd:new Date().valueOf()};var temp=[];for(var p in param){temp.push(p+'='+encodeURIComponent(param[p]||''))};document.write('<iframe allowTransparency="true" frameborder="0" scrolling="no" src="http://hits.sinajs.cn/A1/weiboshare.html?'+temp.join('&')+'" width="'+_w+'" height="'+_h+'"></iframe>')})()</script></div><div id="L2"></div><script type="text/javascript">document.getElementById("L2").innerHTML='<sc'+'ript type="text/javascript"charset="utf-8">(function(){var _w=106,_h=24;var param={url:location.href,type:\'5\',count:\'\',appkey:\'\',title:_ga2+\'…\',pic:\'http://csdnimg.cn/www/images/csdnindex_\'+sj+\'.gif\',ralateUid:\'\',language:\'zh_cn\',rnd:new Date().valueOf()};var temp=[];for(var p in param){temp.push(p+\'=\'+encodeURIComponent(param[p]||\'\'))};document.write(\'<iframe allowTransparency="true" frameborder="0" scrolling="no" src="http://hits.sinajs.cn/A1/weiboshare.html?\'+temp.join(\'&\')+\'" width="\'+_w+\'" height="\'+_h+\'"></iframe>\')})()</'+'script>';</script>