File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes How to control browser instance per URL? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "How to control browser instance per URL?" Watch "How to control browser instance per URL?" New topic

How to control browser instance per URL?

Vis Deo
Ranch Hand

Joined: Jul 02, 2004
Posts: 41
In my web application we have named browser window as = �XYZ� There are different ways user can enter url at browser window, click on favorite or click URL from other web applications to invoke the application. As IE allows to have only one browser instance with same window name, second time invocation over rites the previous instance of browser window and users loose their work. - USERS are not computer savvy & very busy and in their work flow they need to work with many applications at the same time. Do not know how to look for any minimized browser instance. That's why work around is to focus already running browser window.

I am trying to come up with solution using Javascript � to find out if there is a browser window with name XYZ, if so then focus the same other wise invoke new.
I am trying with location.href or

I am getting access denied . Is there any other way to achieve this?


<script language="JavaScript">

function checkeConsultOpen()

//If browser window is not open � it will open about:blank window

WinId ='','XYZ');
var selectedText = WinId.location.href; results in access denied
var array = selectedText.split(':');
// IF open WINDOW IS about:blank, close this and invoke application URL
if (array != -1){

if(array[0] == 'about'){





<P>Place content here. <a href="javascript:checkeConsultOpen();">consult </a> </P>


Eric Pascarello

Joined: Nov 08, 2001
Posts: 15385
The warning message is because you should never open a window without a URL since it is a security issue.

You can detect if a window object still exists in that page and if it open with

if(winName && !winName.closed){
//is open
//not there

If it is open in some other way then there is no way to get a reference too it. Hence why you should avoid using pop ups in applications.

Vis Deo
Ranch Hand

Joined: Jul 02, 2004
Posts: 41

To Clarify more - This is not a pop up detection within application.

I need to control invoking of main url through different sources.

User A has invoked application by typing url at browser. He is working with Data entry for item A. Now he needs to find out how much insurance is covered for A. He uses another application to find out for A. And that application has link to myapp. he clicks on that link that will invoke login page for myapp. This way he will loose all the work he was doing on item A.

What I am looking for is to use history, or cookie or some javascript to detect if there is any browser window for that application is still active on desktop.
I agree. Here's the link:
subject: How to control browser instance per URL?
It's not a secret anymore!