简体   繁体   中英

Javascript onclick only works in chrome, not in firefox or IE

Please could someone help.

I have some social media buttons implemented on our website which work beautifully in Chrome but have discovered don't work in Firefox or IE.

The website is www.mjp.co.uk. When using IE or firefox every button navigates away from the site to a blank white screen, some of which display the function name in the address bar.

Tried the firefox console but doesn't give any errors or clues.

  <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; } </script> <script language="javascript"> 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; } </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> 

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

Run an onlick instead like this

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

See fiddle https://jsfiddle.net/88z7u4kf/2/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM