It's a setting in chrome. You can't control how the browser interprets the target _blank.
It's a setting in chrome. You can't control how the browser interprets the target _blank.
"_blank" is not guaranteed to be a new tab or window. It's implemented differently per-browser.
You can, however, put anything into target. I usually just say "_tab", and every browser I know of just opens it in a new tab.
Be aware that it means it's a named target, so if you try to open 2 URLs, they will use the same tab.
Definitely the second method is preferred because you don't have the overhead of another function invocation:
window.location.href = "webpage.htm";
Hopefully someone else is saved by reading this.
We encountered an issue with webkit based browsers doing:
window.open("webpage.htm", "_self");
The browser would lockup and die if we had too many DOM nodes. When we switched our code to following the accepted answer of:
location.href = "webpage.html";
all was good. It took us awhile to figure out what was causing the issue, since it wasn't obvious what made our page periodically fail to load.
Hey, I'm using an HTML field, and then passing an HTML element into it using jQuery's '.html()' method. The button loads fine into the page, and it launches a new window when clicked, but the target ends up being a concatentation of the URL for the current page, plus the URL we're passing into it.
HTML
<div>
<h4 id="link"></h4>
</div>JavaScript (note, the URL is being pulled from an input text field, and is populated via database lookup)
$(document).ready(function() {
var linkFill = function() {
var url = encodeURIcomponent($('#q54 input').val());
$('#link').html('<input type="button" value="Go To Incident Folder" onclick="window.open('+ "'" + url + "'" + ')" target="_blank">');
console.log('url='+url);
}
$('#q49 input').blur(function() {
setTimeout(linkFill, 2000);
});
});Thoughts?