我的网站上有两个脚本,使用Onclick和Style null会产生jscript错误。我该如何解决这个问题?
1
<script>
document.getElementById("chooser-image").onclick = function () {
Dropbox.choose({
linkType: "direct",
extensions: ['.pdf', '.jpg', '.zip'],
success: function(files) {
var linkTag = document.getElementById('link');
linkTag.href = files[0].link;
linkTag.textContent = files[0].link;
}
});
};
错误: TypeError:无法设置属性&#39; onclick&#39;为null http://www.domain.dk/kontakt-os:1019
2
<!-- LiveZilla Tracking Code (ALWAYS PLACE IN BODY ELEMENT) -->
<div id="livezilla_tracking" style="display:none"></div>
<script type="text/javascript">
var script = document.createElement("script");
script.async=true;
script.type="text/javascript";
var src = "http://www.domain.dk/chat/server.php?a=fd125&request=track&output=jcrpt&intgroup=U3VwcG9ydA__&intid=cm9ubmk_&pref=dXNlcg__&hg=Pw__&hcgs=MQ__&htgs=MQ__&ovlp=MjI_&ovlc=IzczYmUyOA__&ovlct=I2ZmZmZmZg__&ovlml=Ng__&ovlt=Q2hhdCBvbmxpbmU_&ovloo=MQ__&eca=MQ__&ecw=MjUw&ech=OTU_&ecmb=Mjk_&echt=U3DDuHJnc23DpWw,&echst=Q2hhdCBtZWQgb3MgbnU_&ecoht=UXVlc3Rpb25zPw__&ecohst=UGxlYXNlIGxlYXZlIGEgbWVzc2FnZQ__&ecfs=I0YwRkZENQ__&ecfe=I0QzRjI5OQ__&echc=IzZFQTMwQw__&ecslw=Mg__&ecsgs=IzY1OUYyQQ__&ecsge=IzY1OUYyQQ__&nse="+Math.random();
setTimeout("script.src=src;document.getElementById('livezilla_tracking').appendChild(script)",1);
</script>
<noscript>
<h1><img src="http://www.print.dk/chat/server.php?a=fd125&request=track&output=nojcrpt&intgroup=U3VwcG9ydA__&intid=cm9ubmk_&pref=dXNlcg__&hg=Pw__&hcgs=MQ__&htgs=MQ__" width="0" height="0" style="visibility:hidden;" alt=""></h1>
</noscript><!-- http://www.LiveZilla.net Tracking Code -->
错误: TypeError:无法读取属性&#39; style&#39;为null http://www.domain.dk/chat/templates/overlays/chat/jscript/jsextern.js:450&host=www.print.dk
答案 0 :(得分:0)
您的第一个脚本应该在关闭</body>
之前,或<div id="chooser-image" />
之后或document.onload = function{}
之内。对于第二个代码段:它应位于<body>
标记之间的<head>
,不是内。您的错误表明<div id="livezilla_tracking" />
根本不存在。