2017-01-20 5 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 사양 측면에서 코드가 유효하지 않습니다. 링크 안에 버튼이 있습니다. spec에 대해 a 개의 요소는 interactive content을 포함 할 수 없습니다.

+0

감사합니다. 이제 작동합니다. 위의 비트를 업데이트했습니다. – Ash