How To Open A Link In New Tab Using Javascript
I am working on a website, in which I have to open a url from backend. I am using c# now. My problem is that I want to open link in new tab instead of new window. My code is here:
Solution 1:
<a href="javascript:" onclick="window.open('https://www.google.co.in');" target="_blank">Sample Code</a>
Solution 2:
You can use:
window.open(url,'_target')
_target
opens the page in next tab.
Solution 3:
Html Code :
<button onclick="OpenInNewTab();" type="submit">
Javascript Code :
function OpenInNewTab(url) {
var win = window.open(url, '_blank');
win.focus();
}
Change Your Browser Setting.
In FireFox ,
Go To Options -> Tab setting and Check "Open New Windows in a New Tab instead" setting.
This Solution Worked For me .
Solution 4:
I think answer to this question will help , Open a URL in a new tab using JavaScript https://stackoverflow.com/a/30512485/2293686
try like this,
$('#myButton').click(function () {
var redirectWindow = window.open('url', '_blank');
redirectWindow.location;
});
Post a Comment for "How To Open A Link In New Tab Using Javascript"