2013-04-22 31 views
-2

我的頁面末尾有以下代碼。Javascript windows.open錯誤

<script> 
$(".btn_fb").click(function() { 
    window.open("http://www.facebook.com/sharer.php?u="+document.URL+"&amp;t=<%hdl_Title%>", "Facebook", "width=660,height=400,scrollbars=no;resizable=no"); 
    return false; 
});  
$(".btn_tw").click(function() { 
    window.open("http://twitter.com/home?status=<%hdl_Title%> "+document.URL+"", "Twitter", "width=660,height=400,scrollbars=no;resizable=no"); 
    return false; 
});  
$(".btn_li").click(function() { 
    window.open("http://www.linkedin.com/shareArticle?mini=true&amp;url="+document.URL+"&amp;title=<%hdl_Title%>;summary=<%hdl_Title%>", "LinkedIn", "width=660,height=400,scrollbars=no;resizable=no"); 
    return false; 
}); 

$('.btn_go').click(function() { 
    window.open("http://plus.google.com/share?url="+document.URL, 'Google Plus', 'width=660,height=500,scrollbars=no;resizable=no'); 
    return false; 
});  
$(".btn_ma").attr("href", "mailto:?subject=<%hdl_Title%>&body=Hi%0D%0A%0D%0AI thought you may be interested in this: <%hdl_Title%> " + window.location); 

IE9當它擊中腳本的這一部分,我不能針點的錯誤是什麼引發錯誤。 FF不會引發錯誤。

<script> 
    $('.button_google_plus').click(function() { 
     window.open("http://plus.google.com/share?url="+document.URL, 'Google Plus', 'width=660,height=500,scrollbars=no;resizable=no'); 
     return false; 
    }); 
</script> 

NB:代碼:

<%hdl_Title%> 

在CMS設置的參數。

+1

什麼是錯誤消息[IE8變種W的 – 2013-04-22 06:49:50

+0

可能重複= window.open() - 「Message:Invalid argument。」](http://stackoverflow.com/questions/710756/ie8-var-w-window-open-message-invalid-argument) – Phil 2013-04-22 06:51:20

+0

你還應該編碼在查詢字符串上傳遞的URL:'window.open(「http://plus.google.com/share?url=」+ encodeURIComponent(document.URL),...);'。 – 2013-04-22 06:52:57

回答

4

window.open()方法標題不應該將任何空間和窗口屬性可以只包含,;
試試這個

window.open("http://plus.google.com/share?url="+document.URL, 'GooglePlus', 'width=660,height=500,scrollbars=no,resizable=no'); 
+0

+1對';'的好評# – Phil 2013-04-22 06:52:04

+0

非常感謝SJnawali - 做到了。 – rlsaj 2013-04-22 23:18:51