Author |
Topic |
|
T00N
Super User
573 Posts |
Posted - 04 Aug 2006 : 07:44:46
|
Is there some code that you can use to check if a particular url-window is open already?
If no open that url in a new window,
If yes go to that window. |
|
s.dav
Site Admin
Italy
3364 Posts |
Posted - 04 Aug 2006 : 08:53:33
|
You can check if a particular window exists but you cannot see if some browser windows have a particular URL.
Just save the window pointer using a code like this:
var myWin=window.open("myurl")
then you can check using this code if the window exists
if (myWin) { //do something }
or
if (myWin.document.location=="myurl") { // do something }
so the best method is by combining the two like:
if (myWin) { if (myWin.document.location=="myurl") { // do something } }
then you can focus the window using (I'm not sure but it's a thing like this)
myWin.focus();
or
myWin.document.focus();
|
Regards, Davide |
|
|
T00N
Super User
573 Posts |
Posted - 04 Aug 2006 : 13:35:06
|
And if the window exist, will it reload the content or not?
So, if there's a music player playing a song will it start over again or not?
Thanks already! |
|
|
s.dav
Site Admin
Italy
3364 Posts |
Posted - 04 Aug 2006 : 13:40:36
|
no it will not reload the page.
In order to reload the page you have to write
myWin.document.location.reload(true); |
Regards, Davide |
|
|
T00N
Super User
573 Posts |
Posted - 07 Aug 2006 : 23:01:50
|
I'm such a javascript nono [2 puppy]
I found -what I think can be- a solution on experts-exchange but I'm not sure how to properly use it in DHE
This is the code I've found:
<script>
var id= "w001";
newWin=window.open('', id);
newLoc = newWin.location.href.split('/');
newLoc = newLoc[newLoc.length-1];
if(newLoc!='nw.html'){
newWin=window.open('nw.html', id, 'resizable,width=1015,height=700');
} else {
newWin.focus();
}
</script>
I have this hotspot on my site that I want to open a window with a music-player on it. This code should make sure that if that particular window is already open it won't reload. But... how and where can I insert this code? |
|
|
s.dav
Site Admin
Italy
3364 Posts |
Posted - 08 Aug 2006 : 19:53:09
|
Simply use an HTML box ;-) |
Regards, Davide |
|
|
T00N
Super User
573 Posts |
Posted - 08 Aug 2006 : 20:59:40
|
Simply he says
If you don't have a clue what you're doing (like me) this is proving to be quite difficult.
When I put the above code in a HTML box on the page the popup loads immidiately. I want it to load after someone has clicked an image. |
|
|
s.dav
Site Admin
Italy
3364 Posts |
Posted - 09 Aug 2006 : 13:42:28
|
ok, then you can include the code in a javascript function like this:
<script language="javascript" type="text/javascript"> <!--
function openWin() { var id= "w001"; newWin=window.open('', id); newLoc = newWin.location.href.split('/'); newLoc = newLoc[newLoc.length-1]; if(newLoc!='nw.html'){ newWin=window.open('nw.html', id, 'resizable,width=1015,height=700'); } else { newWin.focus(); } }
//--> </script>
then you can create an event on an image (choose OnClick, JavaCall and write the name of the function: 'openWin();')
|
Regards, Davide |
|
|
T00N
Super User
573 Posts |
|
s.dav
Site Admin
Italy
3364 Posts |
Posted - 10 Aug 2006 : 17:21:39
|
Y ;-) |
Regards, Davide |
|
|
|
Topic |
|