Open in new tab after ajax response in javascript is not working,
tried with _newtab and _blank
But none of them is working,
I say,
Is there any solution to get the answer ?
Open in new tab after ajax response in javascript is not working,
tried with _newtab and _blank
But none of them is working,
I say,
Is there any solution to get the answer ?
Share edited Nov 7, 2012 at 10:10 Jaffer 2,96818 silver badges29 bronze badges asked Nov 7, 2012 at 10:04 Mani MMani M 311 gold badge1 silver badge2 bronze badges 3- 1 Is there any change to get the code you're working on? – alexandernst Commented Nov 7, 2012 at 10:08
- Without further information like code-sniplets, which browser/os you're working on and what exactly isn't working a expected, no one'll be able to provide any help... – Nicktar Commented Nov 7, 2012 at 10:24
- I'm using the window.open method after ajax call in javascript – Mani M Commented Nov 7, 2012 at 10:40
4 Answers
Reset to default 5From JavaScript, you cannot open new tabs. You can only open new windows. It's up to the user's browser settings how it opens new windows (be it in a new tab, a new tab in the background, or a new window).
JavaScript does not and cannot even know if your browser supports tab. And it does not have access to anything on the outsides of the browser (unless there's leverage from an extension I suppose).
And as a reminder, there are browsers with no tabs, and others with no windows even. Tabs are just browser features, and never part of any language specification.
Use this -> window.open(YourUrlInsertHere, '_blank');
use window.open() method. For more details check this
Above given answer is great to help but in some way, they are not plete working solution and I came here for finding the same solution and will like to add the working example of it.
var win = window.open('_link is here_', 'name');
if (win) {
//Browser has allowed it to be opened
win.focus();
} else {
//Browser has blocked it
alert('Please allow popups for this website');
}
'name' is a name of the window. Following names are supported
- _blank - URL is loaded into a new tab. This is default.
- _parent - URL is loaded into the parent frame
- _self - URL replaces the current page
- _top - URL replaces any framesets that may be loaded
Depending on the browser's implementation this will work. There is nothing you can do to make it open in a window rather than a tab.
Also find the sample example of it here