Hexagora Forum
Hexagora Forum
Home | Profile | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Dynamic HTML Editor
 Dynamic HTML Editor
 Check if window...
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

T00N
Super User

573 Posts

Posted - 04 Aug 2006 :  07:44:46  Show Profile  Visit T00N's Homepage  Reply with Quote
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  Show Profile  Visit s.dav's Homepage  Reply with Quote
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
Go to Top of Page

T00N
Super User

573 Posts

Posted - 04 Aug 2006 :  13:35:06  Show Profile  Visit T00N's Homepage  Reply with Quote
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!
Go to Top of Page

s.dav
Site Admin

Italy
3364 Posts

Posted - 04 Aug 2006 :  13:40:36  Show Profile  Visit s.dav's Homepage  Reply with Quote
no it will not reload the page.

In order to reload the page you have to write

myWin.document.location.reload(true);

Regards, Davide
Go to Top of Page

T00N
Super User

573 Posts

Posted - 07 Aug 2006 :  23:01:50  Show Profile  Visit T00N's Homepage  Reply with Quote
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?
Go to Top of Page

s.dav
Site Admin

Italy
3364 Posts

Posted - 08 Aug 2006 :  19:53:09  Show Profile  Visit s.dav's Homepage  Reply with Quote
Simply use an HTML box ;-)

Regards, Davide
Go to Top of Page

T00N
Super User

573 Posts

Posted - 08 Aug 2006 :  20:59:40  Show Profile  Visit T00N's Homepage  Reply with Quote
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.
Go to Top of Page

s.dav
Site Admin

Italy
3364 Posts

Posted - 09 Aug 2006 :  13:42:28  Show Profile  Visit s.dav's Homepage  Reply with Quote
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
Go to Top of Page

T00N
Super User

573 Posts

Posted - 09 Aug 2006 :  17:11:30  Show Profile  Visit T00N's Homepage  Reply with Quote
Ok thanks,

so if I replace nw.html (as used in this example) with http://www.madebytoon.nl/dev/mp3player.html it should work?
Go to Top of Page

s.dav
Site Admin

Italy
3364 Posts

Posted - 10 Aug 2006 :  17:21:39  Show Profile  Visit s.dav's Homepage  Reply with Quote
Y ;-)

Regards, Davide
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Hexagora Forum © s.dav Go To Top Of Page
Snitz Forums 2000