Uncaught Reference Error: stLight is not defined (in Chrome only)
Asked Answered
F

6

9

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.

Fane answered 22/4, 2013 at 4:16 Comment(7)
check your console, is there any errors prior to thisLangtry
No, none. Further information: making a local copy of buttons.js, and referencing that, works fine - no error.Fane
it seems to be working fine plnkr.co/edit/tewbsUoOUSPaiEEofsmn?p=previewLangtry
Yeah - 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.Fane
is there a possibility of your script that calls stLight being evaluated before the script from sharethis.com has finished loading?Abfarad
Got the problem, your remote html is running on SSL but the script is from non secured siteLangtry
It's actually not HTTPS.Fane
F
22

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.

Fane answered 22/4, 2013 at 4:35 Comment(1)
"porn mode" made my dayWatthour
B
8

In my case I found it to be a Chrome plugin called "Disconnect". Thanks to @SteveBennet for the clue.

Bromate answered 28/6, 2014 at 7:43 Comment(0)
C
5

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>

ShareThis

Consol answered 7/1, 2016 at 5:30 Comment(0)
L
2

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.

Luella answered 20/1, 2016 at 17:45 Comment(0)
F
0

This can be caused by the Ghostery extension, in addition to the extensions listed in the other answers.

Funerary answered 20/6, 2016 at 23:8 Comment(0)
D
0

If you switched on the SSL on your site, you might want to try re-writing your ShareThis script:

<script type="text/javascript" src="https://ws.sharethis.com/button/buttons.js"></script>
<script type="text/javascript">
  stLight.options({
    publisher:'12345',
  });
</script>
Decare answered 23/3, 2018 at 9:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.