我有一组共享按钮,可在Safari,Chrome和Opera中使用,但不适用于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>
答案 0 :(得分:1)
Firefox被target="_blank"
属性搞糊涂了。 Firefox会打开包含about:blank
网址的新标签页,并尝试执行其中一项功能,例如在新打开的标签中fbCurrentPage
,但该功能并未存在于&#34;空白&#34;}中。文档。
只需从链接中删除target
属性即可。由于函数使用window.open
打开一个新窗口,因此不需要它。
另外,就HTML 5规范而言,您的代码无效。你有链接内的按钮。每个spec的a
元素不得包含interactive content。