2015-09-03 28 views
1

請有人幫忙。Javascript onclick只適用於Chrome瀏覽器,不適用於Firefox或IE瀏覽器

我在我們的網站上實現了一些社交媒體按鈕,這些按鈕在Chrome中運行得非常漂亮,但發現在Firefox或IE中無法使用。

該網站是www.m-j-p.co.uk。當使用IE或Firefox時,每個按鈕從站點導航到空白的白色屏幕,其中一些顯示地址欄中的功能名稱。

嘗試了Firefox的控制檯,但沒有給出任何錯誤或線索。

\t <script language="javascript"> 
 
    function tweetCurrentPage() 
 
    {window.open("https://twitter.com/share?url="+escape(window.location.href)+"&text="+document.title, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=300,width=600');return false; } 
 
\t </script> 
 
\t 
 
\t <script language="javascript"> 
 
\t function twitFollow() 
 
    {window.open("https://twitter.com/intent/follow?screen_name=MedNeg", '', 'menubar=no,toolbar=no,resizable=no,scrollbars=yes,height=580,width=380');return false; } 
 
\t </script>
<li class="but50"><a style="padding-bottom: 18px;" href="javascript:tweetCurrentPage()" target="_blank" alt="Tweet this page" data-via="medneg"><div style="width:50px; text-align:center; float:left"><i class='fa fa-twitter icon' style="font-size: 28px;"></i></div> Share Page</a></li> 
 
<li class="but50"><a style="padding-bottom: 18px;" href="javascript:twitFollow()"><div style="width:50px; text-align:center; float:left"><i class='fa fa-twitter icon' style="font-size: 28px;"></i></div> Follow @MJP</a></li>

+1

的 'onClick' 在所有這些工作。當您從href標籤中的javascript協議切換到*實際*在*'onclick'中執行操作時會發生什麼? (我想知道是否JavaScript的協議已被禁用.. ..) – user2864740

回答

0

運行的點擊數,而不是像這樣

<a href="#" onclick="tweetCurrentPage(); return false" style="display:block; float:right; height:40px; width:100px; cursor:pointer; text-decoration:none">test<a> 

見小提琴https://jsfiddle.net/88z7u4kf/2/

0
<li class="but50"><a style="padding-bottom: 18px;" href="javascript:void(0)" onclick="tweetCurrentPage()" target="_blank" alt="Tweet this page" data-via="medneg"><div style="width:50px; text-align:center; float:left"><i class='fa fa-twitter icon' style="font-size: 28px;"></i></div> Share Page</a></li> 

<li class="but50"><a style="padding-bottom: 18px;" href="javascript:void(0)" onclick="twitFollow()"><div style="width:50px; text-align:center; float:left"><i class='fa fa-twitter icon' style="font-size: 28px;"></i></div> Follow @MJP</a></li> 
相關問題