![](/img/trans.png)
[英]Why does this window.open work on Chrome and FF but not IE?
[英]Track down why window.open does not work
根據需要嘗試在此腳本中使用window.open('url', '_blank')
其他嘗試。 這個,而不是打開新的選項卡,在confirm()
提示后使用不同的邏輯。 邏輯是在頁面中找到“保留”時顯示頁面的一部分,否則重定向到目標頁面。
$.ajax
成功處理程序的結果是重定向是自動的。 兩種重定向方法都不會進行任何更改。
第二種方法的表格:
<form method=\"get\" id=\"formgoregistry\" name=\"goregistry\" action=\"\" target=\"_blank\">
</form>
有問題的javascript函數:
function getRegistryInfo(num) {
// for 2nd method, set the form's action
$('#formgoregistry').attr('action', 'http://somesite.com/somefile?n=somevalue');
var response = $.ajax({
type: 'POST',
url: 'purchases_registry.php',
dataType: 'html',
data: { number: num },
success: function(data) {
console.log('response = '+data);
if (data.indexOf('Reserved') > 0) {
// work with the result
// Code in here works fine
....
}
else {
// wrong data, redirect to outside page
// ** Neither of these method open a new tab
// 1st method
var url = 'http://somesite.com/somefile?n=somevalue';
console.log('url = '+url); // prints the correct url
var w = window.open(url, '_blank'); // NO new tab or error
console.log('window = '+w); // window = undefined
// 2nd method (setting form's action beforehand)
console.log(document.goregistry.action); // prints the correct url
document.goregistry.submit(); // NO new tab or error
}
}
});
}
我想知道是否未定義窗口是問題的一部分,為什么。
使用此腳本在新窗口中打開鏈接:
echo "<form action=\"your_link.php?id=\" method=\"post\" target=\"myWindow\", onsubmit=\"window.open('', this.target, 'width=300,height=400,resizable=no,scrollbars=no');return true;\">
或使用HTML語言:
<form action="your_link.php?idk=$id=" method="post" target="myWindow", onsubmit="window.open('', this.target, 'width=300,height=400,resizable=no,scrollbars=no');return true;">
如果您使用href方法,只需將onsubmit更改為onclick,這就是我所知道的,希望對您有所幫助,祝您好運!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.