2012-07-16 65 views
0

ShareThis小部件在IE9中導致重大問題,所以我想爲瀏覽器禁用它。貝婁你可以看到ShareThis代碼和我試圖禁用它。爲什麼if語句不起作用?該代碼如何禁用IE9?我感謝任何有用的意見或建議。如何禁用IE9的ShareThis?

<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> 

貝婁是我試圖用if語句禁用它。不過ShareThis仍然顯示在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> 
+0

你有什麼問題?以下是一些可能有所幫助的鏈接:https://getsatisfaction.com/sharethis/topics/ie9_issues-1891mj和http://stackoverflow.com/questions/3768539/sharethis-button-does-not-work-on-pages-加載-通AJAX。這也可能有所幫助:http://msdn.microsoft.com/en-us/library/ms537509%28v=vs.85%29.aspx – Peter 2012-07-16 08:28:53

回答

0

可以使用條件註釋:

<!--[if !IE 9]> 
<script src="...sharethis..."></script> 
<![endif]--> 
+0

除了他想要相反的:)他想爲IE9「禁用」ShareThis。所以我相信你的答案是缺少'!'操作符。 – Strelok 2012-07-16 08:30:47

+0

哎呀!是錯過了否定.. :) – techfoobar 2012-07-16 08:37:59

0

IE有這個「偉大」的功能,稱爲「有條件的意見」 :)

在你的情況下,下面的代碼片段將禁用ShareThis碼在大於8的IE版本中加載。

<!--[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]-->