Javascript: Close Popup, Open New Window & Redirect

99封情书 提交于 2019-11-30 10:05:42

Why not just use this in your onclick:

<input type="button" onclick="window.open('http://google.com'); window.close();" />
$('#button').click(function(e)
{
 e.preventDefault();
 window.open('http://www.facebook.com/','_blank');
});

<input type="button" id="button" value="Go facebook">

It works un IExplorer, Firefox, Chrome, Opera and Safari

jQuery code:

$(function(){
    $('#button').click(function() {
        window.close();
        window.open('http://www.google.com/'); 
    });
});

HTML code:

<input type="button" id="button" value="click me">

It works OK in Chrome and IE. In Firefox, you must open this code with window.open.

Try this:

<a href='http://google.com' onclick='window.close();' target='_blank'>LINK</a>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!