Click to See Complete Forum and Search --> : Duplicate windows - preventing


Webskater
02-21-2003, 05:02 AM
I am trying to prevent the situation where users have duplicate copies of the same window open.
I have tried a function in the onload event of the page:
function popme()
{
window.focus
}
This seems to work sometimes and not others. What I need is:
If someone has opened a window with the url of:
www.mydomain.com/productsearch.asp?productID=24
and then tries to open another window with a url of
www.mydomain.com/productsearch.asp?productID=36
... the second window will not open but the first window will display the new url. Any ideas much appreciated.

Charles
02-21-2003, 05:35 AM
If you are trying to foil the intensions of the users who want multiple copies of the same window on their screen then it cannot be done and you are a lothesome cur for even trying. But if your links are unintentionally each opening in a different window then just use the same name as the second parameter passed to the window.open() method.

<a href="http://www.w3.org/TR/REC-html32" onclick="window.open(this.href, 'child'); return false">HTML 3.2</a>

<a href="http://www.w3.org/TR/html4/" onclick="window.open(this.href, 'child'); return false">HTML 4.01</a>

carliedu
02-21-2003, 05:47 AM
Hi Webskater,

the solution I would use, is giving a name for the window object when you are instancing a new windows with window.open('name1-of-html-or-php-file','window1','parameters').

To use the same window with another content, you would use
again window.open('name2-of-html-or-php-file','window1'). You dont need more the parameters because the instance of the window already exists.

Even if you close the window, the instance already exixst and you can use it again (with the same parameters).

I help this can help yuo.

Eduardo De Carli
São Paulo Brazil

Webskater
02-21-2003, 05:51 AM
Originally posted by Charles
[font=georgia]If you are trying to foil the intensions of the users who want multiple copies of the same window on their screen then it cannot be done and you are a lothesome cur for even trying.font]

I am working on an intranet application which is complex. You can, for example, open the purchase order and strock transfer screens from lots of different pages. The system uses pop-up windows so that, if a user is interrupted in their work sequence by a request to do something else, they can do it without losing what they were working on 'underneath'. The problem arises if they have a stock transfer screen open, then someone else asks them to process a different stock transfer, then the phone rings, then they go to lunch - when they get back they won't have a clue what is going on. This is why I am trying to only allow one 'version' of the same window.
I am already giving the window the same name when it is being opened as the second attribute of the window.open method - but it keeps opening new windows - it does not replace the one that is open.

Webskater
02-21-2003, 06:00 AM
Thank you for your replies. My apologies - naming the Window object does work - I was passing through an intermediate window that was checking if stuff existed and was not passing the window name along.

If anyone is interested the function I mentioned in my first post takes care of the situation that occurs when a user opens another window and the window you are interested in loses focus and goes to the back (and appears on the task bar). After the page loads the window pops back off the tack bar with the focus.

Charles
02-21-2003, 06:00 AM
That's odd. It's supposed to work. I'd double check that I really have given them all the same name, try different bowsers and then give up and use the "target" attribute.