Functionality of window.open() in google chrome - javascript

I am not a very experienced javascript programmer by any means, but I am trying to prototype something for design purposes and I need some help. Here are some questions I have about window.open() in chrome
How do I get the page to open in a new window. Not just another chrome tab.
Is it possible for me click a link in one window and have it open in some other window already open on my browser.
If I can open it in another window it is possible to specify which tab. Whether it be a tab that's already open or opening a new tab.
Thanks

I would like to quote other answers from helpful posts that will go more in depth to what you need to know, all the answers here are in javascript:
Open a URL in a new tab
also
Open URL in New Window with Javascript
open url in new tab or reuse existing one whenever possible
also
I want to open a new tab instead of a popup window
You cannot open new windows or new tabs that your Javascript does not already know about because its outside its scope.
I hope this helps, please feel free to comment if you need anything further!

Related

Is it possible to determine if my website page is on a new window or is it one of the tabs?

One function in my website requires that the website be opened in a new window rather than a new tab.
Is there any way to determine if the page is opened in a new window or a new tab and show an informative message to user?
-----Edited and added below to distinguish from an already asked and answered question.-------------
I do not want to open my page in a new window if it has already been opened in a new window.
I want to determine if the page is opened in a new window and if not, to provide an informative message to the user and give the option to open my website in a new window, if the user so chooses.
One of the functions on my website involves resizing the window to half its original size. Resizing is not possible inside a tab and hence this question.
The workflow is:
1) Open my website.
2) Determine if it is in a new window.
3) If yes, then continue.
4) If no, then advise visitor about the need to open in a new window and provide button, "Open in a new window?".
5) If clicked, Open the website in a new window (with a unique window name) and change focus to the new window.
6) If not clicked - continue as a tab.
Some functions which require resizing, will not work properly as a tab, though.
--------End of edit------------
You can check the history.lenght to know that if a new page/tab is opened or not. but totally knowing the difference between window is tab is a bit complex. you may check the menubar.visible too, to get hint for your problem.
Overally please check the following link for further comments and ideas:
How do identify whether the window opened is a pop up or a tab

window.open() Opens as popup in chrome, But I need it to be open in another tab instead

I have a timeout function call, inside that I want to trigger a " window.open(redir_URL,"_blank"); " which should open in a new tab, but its opening as a popup.
Also its not user initalted event, its a javascript call.
Ref: http://upshots.org/javascript/window-open-opening-in-popups-vs-new-tabs-with-set
With ref to this, I tried to trigger a click event , but that also opens as a popup.
Any one please help me out this?
Chromium ticket: http://code.google.com/p/chromium/issues/detail?id=20189
This is a browser setting and not something you can control with code. In my browser, your "window.open" will open a new tab, because that's what I have mine set up to do. In others' browsers, it might open a new window.
Reference:How do you open a new tab in chrome using HTML/JS?

Way to open popup in a new window

Is there any way to force IE8 to open new window only in a pop-up? I don't want to change the browser settings. I want to open it and throw Javascript window.open(). Firefox is opening it in a new window but IE8 is opening the same in a new tab. Please suggest.
hold a SHIFT button while you click on an Internet hyperlink on your browser screen. This will force the link to open in a new window
You cannot control whether a browser opens a window in a new tab or new window.
Although, one work around is to set height and width dimension in the call to window.open() alongwith disabling the addressbar and statusbar.
window.open ("http://www.example.com", "mywindow","status=0,toolbar=0,height=600,width=900");
It worked for my case, I'm not sure if this satisfies your question.

JavaScript close tab after window.open()

I've got a page which open a new window fullscreen but it still has the other page (the one which re-directs) behind so when you close the new window you are taken back to a blank page.
Is there a way to open a new window and then close the tab which is now inactive?
Currently I have some javascript like this
window.open("http://website.co.uk");
Thanks
You can technically use window.close() on the opening tab, but browsers usually will not allow JavaScript to close windows that it has not opened. Can you redirect to some useful page that the user can use once they have closed the window?
If you can add some JavaScript code to the page being opened, I think you can use window.opener.close() to close the original window. I tested it in IE8, the browser will ask for confirm before close the original window.

How can I modify this bookmarklet to work on a tab instead of a new window?

When you put this in your browser it opens a simple notepad to type in.
I don't know enough about javascript to alter it but I would like to make it so it DOESN'T open in a new window but rather in the current window or another tab.
Is this even possible?
javascript:pwin=window.open('','_blank','menubar=yes,scrollbars=yes,location=no,height=450,width=350');pwin.document.body.contentEditable='true';pwin.document.designMode='on';void(0);if(window.focus){pwin.focus()};
Technically, window.open does not always open in a new window. You can use _self instead of _blank, and it will open in the same window. Or use _parent and it will open in the current frame's parent.
Window.open always opens this in a new window.
Instead I think you can try window.location. Not tried tough.
Ok did a little digging and there is nothing you can do that will guarantee that it will open in a new tab. However if you remove the width and height parameters some browsers will open in a new tab if user preferences haven't overridden this behavior. See this post (2nd answer in list) Stackoverflow post
If you aren't looking to open a window, then don't window.open()
Setting window.location should do the trick, as pointed out by Sachin

Categories