PDA

View Full Version : Issue in window.open() when called from inside a function



wasima
23 Jul 2012, 8:27 AM
When i use window.open('http://www.google.com') inside a function it opens as a pop up instead of opening as a new window in different tab . I dont need a pop up i want a new window to be opened in a new tab . Can anyone help me please ?

scottmartin
23 Jul 2012, 1:49 PM
Have you tried to add the target param?



var newWindow = window.open('url', '_blank');


Scott

wasima
23 Jul 2012, 8:16 PM
Hi Scott,
This is what i am doing
xmlStore.on('load', function () {
xmlStore.data.each(function() {
if(fvConstants.context==this.data['id']) {
file = this.data['help-filename'];
window.open(file,'_blank');

}


});


});
I tried ur suggestion but it still opens as a pop up and not in a new window

sword-it
24 Jul 2012, 3:27 AM
Hi!

There's no way to open links with JavaScript to new tabs , the best you can do is open a new window or instruct the user to use middle-click or ctrl+click.
see the link to instruct user here,
http://www.dynamicdrive.com/forums/archive/index.php/t-19843.html

The tab behavior is totally controlled by the end-user, as it should be.
Also, the browsers do have a user preference as regards to Windows OR Tabs.

Firefox:-
Tools > Options > Tabs > "Open new windows in a new tab instead".

Opera:-
Tools > Preferences > Advanced > Tabs > [Additional tab options...] > "Open windows instead of tabs.

IE:-
Tools > Internet Options > General > Tabs [Settings] > "Always open pop-ups in a new window" (selected by default) OR "Always open pop-ups in a new tab".