2017-01-20 57 views
1

我有一套共享按钮,在Safari,Chrome和Opera中工作,但不是Firefox。他们只是在Firefox中打开一个新的空白窗口,为什么会这样呢?为什么这些分享按钮在Firefox中不起作用?

<script type="text/javascript"> 
function fbCurrentPage() 
{window.open("https://www.facebook.com/sharer/sharer.php?u="+escape(window.location.href)+"&t="+document.title, '', 
'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=300,width=600');} 
function twitterCurrentPage() 
{window.open("https://twitter.com/share?u="+escape(window.location.href)+"&t="+document.title, '', 
'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=300,width=600');} 
function gplusCurrentPage() 
{window.open("https://plus.google.com/share?url="+escape(window.location.href)+"&t="+document.title, '', 
'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=605,width=400');} 
</script> 

<div class="social"> 
<a href="javascript:fbCurrentPage()" class="facebook">Facebook</a> 
<a href="javascript:twitterCurrentPage()" class="twitter">Twitter</a> 
<a href="javascript:gplusCurrentPage()" class="gplus">Google+</a> 
</div> 

回答

1

Firefox被target="_blank"属性混淆。 Firefox使用about:blank URL打开新选项卡并尝试执行其中一个功能,例如fbCurrentPage在新打开的选项卡中,但该功能不存在于“空白”文档中。

只需从链接中删除target属性即可。这是不需要的,因为功能使用window.open,它打开一个新窗口。

而在附注中,您的代码在HTML 5规范方面无效。链接中有按钮。 a元素每spec不允许包含interactive content

+0

谢谢!现在起作用了,我已经更新了上面的那些位。 – Ash

相关问题