aspose file tools*
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
Author

How to control browser instance per URL?

Vis Deo
Ranch Hand

Joined: Jul 02, 2004
Posts: 40
In my web application we have named browser window as window.name = �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 window.name

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


<HTML>
<HEAD>
<TITLE>testopenwindow.html</TITLE>
</HEAD>

<script language="JavaScript">



function checkeConsultOpen()
{

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

WinId = window.open('','XYZ');
alert(WinId.location.href);
alert(WinId.name);
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){
alert(array[0]);
WinId.close();

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


WinId1 =window.open('http://myapp.mycom.org');
WinId1.focus();
}

}

}

</script>

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

<br>

</BODY>
</HTML>
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
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
}
else{
//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.

Eric
Vis Deo
Ranch Hand

Joined: Jul 02, 2004
Posts: 40
Thanks.

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 http://myapp.mycom.org 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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to control browser instance per URL?