Javascript 在新选项卡中提交表单并将现有页面重定向到xyz.html

Javascript 在新选项卡中提交表单并将现有页面重定向到xyz.html,javascript,jquery,html,Javascript,Jquery,Html,函数reDir(){ window.onbeforeunload=null; window.location=”http://www.google.com"; } 试试下面的方法 window.location.href = 'http://www.google.com'; // Sets the new location of the current window. window.location = "http://www.google.com"; // Sets the ne

函数reDir(){
window.onbeforeunload=null;
window.location=”http://www.google.com";
}




试试下面的方法

window.location.href = 'http://www.google.com';



// Sets the new location of the current window.
window.location = "http://www.google.com";

// Sets the new href (URL) for the current window.
window.location.href = "http://www.google.com";

// Assigns a new URL to the current window.
window.location.assign("http://www.google.com");

// Replaces the location of the current window with the new one.
window.location.replace("http://www.google.com");

// Sets the location of the current window itself.
self.location = "http://www.google.com";

// Sets the location of the topmost window of the current window.
top.location = "http://www.google.com";
试试下面的方法

window.location.href = 'http://www.google.com';



// Sets the new location of the current window.
window.location = "http://www.google.com";

// Sets the new href (URL) for the current window.
window.location.href = "http://www.google.com";

// Assigns a new URL to the current window.
window.location.assign("http://www.google.com");

// Replaces the location of the current window with the new one.
window.location.replace("http://www.google.com");

// Sets the location of the current window itself.
self.location = "http://www.google.com";

// Sets the location of the topmost window of the current window.
top.location = "http://www.google.com";

setTimeout
window.location.href
应该可以做到这一点

函数reDir(){
setTimeout(函数(){
window.onbeforeunload=null;
window.location.href=http://www.google.com';
}, 10);
}





setTimeout
window.location.href
应该可以做到这一点

函数reDir(){
setTimeout(函数(){
window.onbeforeunload=null;
window.location.href=http://www.google.com';
}, 10);
}





我也尝试过这个,但没有成功,表单提交并在新选项卡中正常工作,但包含表单的原始选项卡根本没有重定向。谢谢,超时功能正常工作,不确定没有它为什么不工作。因为浏览上下文。。参考这个。。每个浏览上下文都有一个特定的来源、活动文档的来源以及按顺序列出所有显示文档的历史记录。1对1..我也尝试过这个,但不起作用,表单提交并在新选项卡中正常工作,但包含表单的原始选项卡根本没有重定向。谢谢,超时功能起作用,不确定没有它为什么不起作用。因为浏览上下文。。参考这个。。每个浏览上下文都有一个特定的来源、活动文档的来源以及按顺序列出所有显示文档的历史记录。1比1..太棒了,菲尔,成功了!如果你不介意解释的话,我的方法出了什么问题?酷!;)我想您必须使用
setTimeout
,因为同时触发了两个事件(打开新选项卡和函数调用)<代码>窗口。位置是一个对象,因此必须设置正确的属性。在本例中,它的
href
。如果它解决了你的问题,请将此标记为正确答案。太棒了,菲尔,这成功了!如果你不介意解释的话,我的方法出了什么问题?酷!;)我想您必须使用
setTimeout
,因为同时触发了两个事件(打开新选项卡和函数调用)<代码>窗口。位置是一个对象,因此必须设置正确的属性。在本例中,它的
href
。如果它解决了你的问题,就把它标记为正确答案。。