Wondering how to open many new windows with Javascript. I have found plenty of places on the internet that show you how to open a new browser window with Javascript, but I want to open a new UNIQUE window. For Example.
I have two links on a page. the user clicks on both links and they are both opened in the same window. I want each link to open a new window WITH JAVASCRIPT.
Another Example.
I just opened a window with javascript and I have a link inside my newly opened window. I click on the link and it opens in the same window. I want to pop it out of that window WITH JAVASCRIPT, NOT use the same window.
Help?
window.open('page.html','WindowTitle','width=400,height=200')
Like the previous poster said, you want window.open(...)
var WindowObjectReference = window.open(strUrl, strWindowName [, strWindowFeatures]);
https://developer.mozilla.org/En/DOM/Window.open
Make sure that you have different strWindowName for each call since that determines which window the URL is opened in.
Related
I have noticed one thing when you press ctrl button + click a button or a link a new windows open in the same browser, I want same situation like that, I already studied the window.open() method which open a new window but with the latter method i am directed to the new window, I just to stay on the first page , not the one popups.
You can not decide how the user's browser handles the open window event, but to trigger the new window or new tab (based on the user's settings) you can do the following:
window.open(url,'_blank');
The _blank indicates the new window or tab to the browser.
The problem is when calling window.open(url, name) for a specific page, it is always opened in a new window, instead of the SAME one. In other words, every time this statement is executed, a new window is opened, while what I want is only ONE new window is opened and all the following calls will open the page in that new window. The name parameter in this javascript statement doesn't work for this case obviously. It only happens with IE11(Couldn't try other versions of IE).
When I tried opening window of my own pages, it worked as expected. But that specific page doesn't. That page is on the same host but out of my control. I don't know what exactly it does. The only thing I know is it relaxes document.domain. But even if I change the domain of the main page to be the same as that page's, it still doesn't work.
Does anybody know what's the root cause?
Thanks in advance!
The problem might be due to Internet Explorer settings.
Under Internet Options
Click Settings under Tabs
Under When a pop-up is encountered:, select Always open pop-ups in a
new tab
Under Open links form other programs in:, select A new tab in the
current window
to do that you want
window.location not open
open will open a new window/tab
EG
window.location = "http://www.google.com"
to navigate to google.com in the same window/tab
I have a page with several links that open a separate window with varying content. My goal is to open a window for each and every such link using JavaScript. My problem is as follows:
let's assume:
- i have two links on the page, lnkDoWorkOne and lnkDoWorkTwo
- lnkDoWorkOne opens a window with url = WorkOne.aspx which in turn does some work upon loading
- lnkDoWorkTwo opens a window with url = WorkTwo.aspx which also does some work
In my present solution when I click lnkDoWorkOne then a new window opens with WorkOne.aspx and works just fine. Then when I click lnkDoWorkTwo, then there's no new window at all but the contents of the previously opened window are simply replaced by WorkTwo.aspx. I need to have BOTH windows open with WorkOne.aspx and WorkTwo.aspx so that the user can view the contents in parallel.
Does anyone know how to achieve this?
Are you giving the same window name to the both window.open calls? If so, change the name of the window and you should get two separate windows.
window.open('WorkOne.aspx', 'window1');
...
window.open('WorkTwo.aspx', 'window2');
I am building a web app, for myself, to control some servers on my home network, and discovered what I think is very odd behavior in Firefox.
If you open a pop-up, via javascript, in Firefox, is it then impossible to open a new tab, via javascript in that pop-up? If not impossible, how do you do it?
Given a clean, default Firefox 3.6.3 installation...
If I open a page in Firefox and then call
var my_window = window.open('http://www.google.com','_blank','top=10');
A brand new "pop-up" window opens.
However, if instead I call
var my_window = window.open('http://www.google.com');
A get a new tab.
HOWEVER...
If I call the first version
var my_window = window.open('http://www.google.com','_blank','top=10');
And then in the new "pop-up" that opens, I call
var my_window = window.open('http://www.google.com');
It opens a new tab in the original window, not a new tab in the pop-up.
This seems very odd, and not intuitive at all. Why would the call in the pop-up open a tab in the "parent" window?
This behavoir is a browser setting, the user desides if he opens a new window or a new tab when he opens a link. You cannot manipulate this.
Only thing you can manipulate is if you open the link in a "blank" screen, current window or certain frame
They are both children of the original document and modal windows generally do not have children. They are the rough equivalent of modal dialogs in the Windows OS. In fact, that is what IE does; it even calls it a modal dialog. I think that what is being described here is a new browser instance and not a window with tabs.
I have same ancors/hyperlink in my html file. These point to a new website outside my site.
So I want that when the user clicks the link it should open a new tab or window. My website page should not be closed.
How can it be done?
open in tabs: there is nothing programatically that you can do to accomplish that, the only thing I'm thinking of is set the browser to open new links in tabs instead of new window...
to open in a new window all you need is to place a target in your anchors
click here
and, by the way there are more options to the target
target="_blank"
opens in a new Blank window
target="_parent"
opens in a Parent window (used when dealing with iframes and you want to open the link in other frame)
target="_self"
opens in it's own/self window (used when dealing with iframes and you want to open the link in the current frame)
target="_top"
opens in the top of all frames (it will open on top of all frames in the page, like a no-frame page will be display)
Click me to open in a new tab/window
Load the linked document into a new
blank window. This window is not
named.
If there is no existing window or
frame with the same name as specified
in the target, a new window is opened
with a name equal to the value of the
target.
Its the setting in a browser that determines whether to open the page in a new tab or in a new window.
Just add target="_blank" to the <a> tag
Click here
The easiest way is to use the target attribute in your anchors and set it to _blank:
Worse Than Failure
This is a dupe of opening links in the same window or in a new (tab) and https://stackoverflow.com/questions/118567/is-there-ever-a-good-reason-to-force-opening-a-new-browser-window. Basically - no. And there shouldn't be a way - you shouldn't impose your surfing preferences on unsuspecting others.