Uncaught Reference Error: stLight is not defined (in Chrome only)
Solution 1
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).
EDIT It's Collusion's "block known tracking sites" feature.
Solution 2
In my case I found it to be a Chrome plugin called "Disconnect". Thanks to @SteveBennet for the clue.
Solution 3
In my case I replaced
<script type="text/javascript" src="http://w.sharethis.com/button/buttons.js"></script>
this by
<script type="text/javascript" src="https://ws.sharethis.com/button/buttons.js"></script>
Solution 4
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>
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.
Steve Bennett
Freelance Mapbox GL JS, vector tile and VueJS guru, available for consulting work. See http://hire.stevebennett.me. I specialise in high performance web map data visualisations, and custom vector tile generation for the Mapbox platform. I use NodeJS for back-end data processing, and VueJS for front end. My blog: http://stevebennett.me My NPM profile: https://www.npmjs.com/~stevage (Please don't email me asking for help with a StackOverflow question.)
Updated on July 21, 2022Comments
-
Steve Bennett almost 2 years
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:
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.
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.
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?
The static (generated) code is here. It won't run from Dropbox though.
-
Arun P Johny about 11 yearscheck your console, is there any errors prior to this
-
Steve Bennett about 11 yearsNo, none. Further information: making a local copy of buttons.js, and referencing that, works fine - no error.
-
Arun P Johny about 11 yearsit seems to be working fine plnkr.co/edit/tewbsUoOUSPaiEEofsmn?p=preview
-
Steve Bennett about 11 yearsYeah - as I said, a local static copy of the HTML page works fine for me as well. I'm really curious why it fails under this one circumstance: remote deployment, Chrome, remote script.
-
akonsu about 11 yearsis there a possibility of your script that calls
stLight
being evaluated before the script from sharethis.com has finished loading? -
Arun P Johny about 11 yearsGot the problem, your remote html is running on SSL but the script is from non secured site
-
Steve Bennett about 11 yearsIt's actually not HTTPS.
-
-
baldrs about 9 years"porn mode" made my day