javascript 未捕获的参考错误:stLight 未定义(仅在 Chrome 中)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16139354/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Uncaught Reference Error: stLight is not defined (in Chrome only)
提问by Steve Bennett
My web page ends thus:
我的网页这样结束:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">var switchTo5x=false;</script>
<script type="text/javascript" src="http://w.sharethis.com/button/buttons.js"></script>
<script type="text/javascript">
stLight.options({publisher: "ur-24e62f76-1f66-e3aa-1190-c533b729ca11", doNotHash: true, doNotCopy: true, hashAddressBar: false});
</script>
<script type="text/javascript" src="/static/bootstrap/js/bootstrap.js"></script>
</body>
</html>
In FireFox and Safari, it behaves. In Chrome:
在 FireFox 和 Safari 中,它的行为。在 Chrome 中:
Uncaught ReferenceError: stLight is not defined nectar-tugg-art:229
(anonymous function)
In other words, the code at w.sharethis.com/button/buttons.js has failed to execute, and hence, failed to define the stLight variable.
换句话说,w.sharethis.com/button/buttons.js 上的代码未能执行,因此未能定义 stLight 变量。
The page is part of a Django web application running on a remote server. Saving the generated HTML page locally, then viewing in Chrome, works correctly.
该页面是在远程服务器上运行的 Django Web 应用程序的一部分。将生成的 HTML 页面保存在本地,然后在 Chrome 中查看,工作正常。
At this point I'm stuck. Something to do with the cross domain security model? There aren't any security exceptions.
在这一点上,我被困住了。与跨域安全模型有关吗?没有任何安全例外。
Some weird interaction with the other javascript files?
与其他 javascript 文件的一些奇怪的交互?
The static (generated) code is here. It won't run from Dropbox though.
静态(生成的)代码在这里。但它不会从 Dropbox 运行。
回答by Steve Bennett
Ok, think I may have found it: the site runs fine in Chrome's incognito(porn) mode. So I strongly suspect I've got some kind of extension that's interfering with it (like Do Not Track or something).
好吧,我想我可能已经找到了:该网站在 Chrome 的隐身()模式下运行良好。所以我强烈怀疑我有某种干扰它的扩展(比如不跟踪或其他东西)。
EDIT It's Collusion's "block known tracking sites" feature.
编辑 这是 Collusion 的“阻止已知跟踪站点”功能。
回答by Brett
In my case I found it to be a Chrome plugin called "Disconnect". Thanks to @SteveBennet for the clue.
就我而言,我发现它是一个名为“断开连接”的 Chrome 插件。感谢@SteveBennet 提供线索。
回答by Bimal Dev
回答by Hassan Ali Shahzad
In Magento stLight is not defined:
This can be resolved by following:
<script type="text/javascript">
window.onload = function(){ stLight.options({publisher: "ur-24e62f76-1f66-e3aa-1190-c533b729ca11", doNotHash: true, doNotCopy: true, hashAddressBar: false});}
</script>
在 Magento stLight 中没有定义:这可以通过以下方式解决:
<script type="text/javascript">
window.onload = function(){ stLight.options({publisher: "ur-24e62f76-1f66-e3aa-1190-c533b729ca11", doNotHash: true, doNotCopy: true, hashAddressBar: false});}
</script>
Issue (I think) is js file http://w.sharethis.com/button/buttons.js
load after the script in which this function exists. so easiest solution in my mind is window.onload, may have other good solutions.
问题(我认为)是http://w.sharethis.com/button/buttons.js
在此函数存在的脚本之后加载js 文件。在我看来,最简单的解决方案是 window.onload,可能还有其他好的解决方案。
回答by Brad Werth
回答by The Whiz of Oz
If you switched on the SSL on your site, you might want to try re-writing your ShareThis script:
如果您在您的站点上打开了 SSL,您可能想尝试重新编写您的 ShareThis 脚本:
<script type="text/javascript" src="https://ws.sharethis.com/button/buttons.js"></script>
<script type="text/javascript">
stLight.options({
publisher:'12345',
});
</script>