我想打开一个新窗口(onclick)到Facebook上的页面(facebook.com/sharer.php)。
但是,如果由于弹出窗口阻塞而失败,我想检测它并改为链接(新标签页)。
我该怎么做?
答案 0 :(得分:4)
if(!window.open()){
//pop up failed.
}
答案 1 :(得分:1)
$('#anchor').click(function(){
if(!window.open()){
//pop up failed.
window.open('http://www.example.net/'); // open url in new tab
window.location = "http://www.example.net/" // open in current window
}
});