I should preface this with the fact that I know virtually nothing about javascript and, apart from very rare situations like this, I don’t really plan on using it much. So please forgive me for not having tried to learn more about it in order to try and solve this problem for myself.
The Situation:
I frequently like to make use of popout browser windows. To do this I created a bookmark in my browser that contains this small piece of Javascript I copied from somewhere – I can’t remember where – and adapted to suit my screen:
javascript:%20var%20WindowPopup%20=%20window.open(window.location.href,'PopUp','left=1150,top=830,width=660,height=410,scrollbars=yes,location=no,status=no');
The Problem:
As things stand, when there is an existing popout window and I select the bookmark again, the same popout window is re-used if I’m at the same site, otherwise a new popout window is created. But there are many occasions when I would like to override this default behaviour.
Three Qustions:
-
How can I force popouts to always open in a new window?
-
How can I force popouts to always re-use an existing window?
-
Combining the previous two options: is it possible to detect if there is an existing popout window and prompt me as to whether I want to re-use it or open a new one?
Your help will be greatly appreciated.
The String “PopUp” in your bookmarklet is the name of your popup window. If you create another popup window using the same name, the already opened window will be reused.
If you want to get around this behavior, you will have to create a popup window with a unique name every time.
The following bookmarklet code will append a timestamp to the name of the popup window creating a unique name:
This should work unless you’re opening multiple popups within a millisecond.