0

The ShareThis widget causes significant problems in IE9, so I want to disable it for the browser. Bellow you can see the ShareThis code and my attempt to disable it. Why is the if statement not working? How can this code be disabled for IE9? I appreciate any helpful comments or suggestions.

<script type="text/javascript">var switchTo5x=true;</script>
     <script type="text/javascript"
     src="http://w.sharethis.com/button/buttons.js"></script>
     <script type="text/javascript" src="http://s.sharethis.com/loader.js"></script>

     REST OF CODE

     <script>
     var options={ "publisher": "3662a59e-5e0d-4969-8567-735aca70d6d1",
     "position": "left", "ad": { "visible": false, "openDelay": 5,
     "closeDelay": 0}, "chicklets": { "items": ["facebook", "twitter",
     "linkedin", "email", "pinterest", "sharethis"]}};
     var st_hover_widget = new sharethis.widgets.hoverbuttons(options);
     </script>

Bellow is my attempt to disable it with an if statement. However ShareThis still shows up on IE9.

 <script type="text/javascript">
 if (navigator.appName="Microsoft Internet Explorer")
 {
 }
 else
 {

 <script type="text/javascript">

 var switchTo5x=true;</script>

 <script type="text/javascript"
 src="http://w.sharethis.com/button/buttons.js"></script>
 <script type="text/javascript" src="http://s.sharethis.com/loader.js"></script>
 }
 </script>

 REST OF CODE

 if (navigator.appName="Microsoft Internet Explorer")
 {
 }
 else
 {
 <script>
 var options={ "publisher": "3662a59e-5e0d-4969-8567-735aca70d6d1",
 "position": "left", "ad": { "visible": false, "openDelay": 5,
 "closeDelay": 0}, "chicklets": { "items": ["facebook", "twitter",
 "linkedin", "email", "pinterest", "sharethis"]}};
 var st_hover_widget = new sharethis.widgets.hoverbuttons(options);
 </script>
 }
 </script>
  • What problems are you having? Here are some links that might help: https://getsatisfaction.com/sharethis/topics/ie9_issues-1891mj and http://stackoverflow.com/questions/3768539/sharethis-button-does-not-work-on-pages-loaded-via-ajax. This might also help: http://msdn.microsoft.com/en-us/library/ms537509%28v=vs.85%29.aspx – Peter Jul 16 '12 at 08:28

2 Answers2

0

You can use conditional comments:

<!--[if !IE 9]>
<script src="...sharethis..."></script>
<![endif]-->
techfoobar
  • 65,616
  • 14
  • 114
  • 135
0

IE has this "great" feature called "conditional comments" :)

In your case the following snippet will disable the ShareThis code from loading in IE version greater than 8.

<!--[if lt IE 9]> 
<script type="text/javascript" src="http://w.sharethis.com/button/buttons.js"></script> 
<script type="text/javascript" src="http://s.sharethis.com/loader.js"></script> 
<script> // .. rest of sharethis init code</script>
<![endif]-->
Strelok
  • 50,229
  • 9
  • 102
  • 115