我想在新标签页中打开url
。
我正在使用以下代码在新标签页中打开网址。
var url = "/Billing/DownloadEDIForMultipleClaim?month=" + month + "&BillRequestIds=" + billRequestIds.join(',') + "&PatientIDs=" + patientIds.join(',');
window.open(url, '_blank'); //exception here
但通过异常Uncaught TypeError: Cannot read property 'open' of undefined
我也使用了以下内容。
var url = "/Billing/DownloadEDIForMultipleClaim?month=" + month + "&BillRequestIds=" + billRequestIds.join(',') + "&PatientIDs=" + patientIds.join(',');
var win = window.open(url, '_blank');
if(win) {
//Browser has allowed it to be opened
win.focus();
} else {
//Broswer has blocked it
alert('Please allow popups for this site');
}
我已经看到了相关的问题。
How to open a URL in a new Tab using javascript or jquery?
How to open a link in new tab using javascript
但这不适合我。
答案 0 :(得分:0)
这可能有用: http://jsfiddle.net/vraCM/12/ 似乎这段代码片段包含了您需要的工作。
$(function() {
$("a[href^='http']:not([href*='jsfiddle.net'])").each(function() {
$(this).click(function(event) {
event.preventDefault();
event.stopPropagation();
window.open(this.href, '_blank');
}).addClass('externalLink');
});
});
js小提琴包含的代码可以操作以适应有关警报或新窗口中弹出窗口的参数等。
此外,这篇文章可能值得一读。 http://www.jqueryfaqs.com/Articles/Open-new-tab-in-browser-using-jQuery.aspx