0
其他尝试在此脚本中使用window.open('url', '_blank')
可按需要工作。这一个,不打开新标签,在confirm()
提示符后面使用不同的逻辑。如果在其中找到“保留”或者重定向到目标页面,逻辑是显示页面的一部分。追踪为什么window.open不起作用
作为$.ajax
成功处理程序的结果,重定向是自动的。重定向的两种方法都不做任何更改。
形式第2种方法:
<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
}
}
});
}
我想知道如果未在所述窗口的问题和原因的一部分。
提交需要用JavaScript。 'window.open('url');'或'document.goregistry.submit();' – David