...

View Full Version : domain checker script?



tcserpa
07-29-2002, 03:27 PM
okay, so i'm working on this site, the owners of which wish to have uninterupted music playing throughout the duration of the user's visit.

i have cobbled together a script which opens a "popunder" window with an embedded sound file. so far so good.

what i need to do now is figure out how to determine when a user leaves the site and closes the music window. i have a script which will (almost) do it. however it uses an "unUnload" command so it closes the window whenever the user leaves any page.

any thoughts?

ShriekForth
07-29-2002, 05:32 PM
There is an HTML solution. You could have the music play from a hidden, or small frame. Once they click on a link that breaks the frameset it would stop. As long as the music frame does not get changed, the music would continue un-inturrpted.

Of course this brings up the issues with frames, bookmarking, etc..

ShriekForth

tcserpa
07-29-2002, 05:45 PM
a good idea, but one i wish to avoid for the reasons listed at the ends of your post.

this may be the dumbest question ever, but if i put an existing site into a frame won't i need to add a target to every link to keep it in the frame?

ShriekForth
07-30-2002, 02:58 PM
No, you can set a "base" target for the page, then you would only have to change the target of links going away from your site.

<base target="mainFrameName">

But as long as you are trying to onlcy change the pages in that one frame, you could probaby get away with just putting a target on the external links.

ShriekForth

tcserpa
07-30-2002, 03:06 PM
excellent.

thank you.

Roy Sinclair
07-30-2002, 07:01 PM
One way you can do it is to have the popup page monitor the href of the main window. As soon as the popup gets an error (which you'll have to trap) the main window has either been closed or is no longer "on site" and the popup can simply close itself.

tcserpa
07-30-2002, 07:17 PM
that is a very good idea that i have no idea how to accomplish.

i've been trying to do it in the parent window, but using the child seems much more elegant.

Roy Sinclair
07-30-2002, 07:49 PM
Totally untested but the following code should do the trick:



<script type="text/javjascript">
function errorTrapped(eMsg,eUrl,eLine)
{ window.close(); }
window.onerror = errorTrapped;
</script>
<body onload="setInterval('mainHref = parent.location.href'),2000)">

tcserpa
07-30-2002, 08:59 PM
thanks for the reply, but i don't quite get it.

-----------your code----------------------
<script type="text/javjascript">
function errorTrapped(eMsg,eUrl,eLine)
{ window.close(); }
window.onerror = errorTrapped;
</script>


<body onload="setInterval('mainHref = parent.location.href'),2000)">
-----------------------------------------------------
i see the close window command, and see that it is called on an error.

and the setInterval bit checks the parent window's location every 2000 somethings, right?

the mainHref is set as the parent's location when the child is loaded. so, if the parent's current location doesn't match it's original location the child should close, right?

something is not working.

forgive me, i'm slower than most.

i'm afraid i'm gonna have to find someone to help me in person with this as deadlines draw near, and i can't expect you (or others like you) to write tons of code for me.

thanks again.

Roy Sinclair
07-30-2002, 09:45 PM
and the setInterval bit checks the parent window's location every 2000 somethings, right?

Every 2000 milliseconds which translates to every two seconds.


the mainHref is set as the parent's location when the child is loaded. so, if the parent's current location doesn't match it's original location the child should close, right?

No, mainHref is set to the value of the parent window's href but the only reason to do this every two seconds is simply to access the href. As long as the access is permitted by the browser the user is still "on site".


i see the close window command, and see that it is called on an error.

This is the meat of the process, when a javascript error occurs (any error, it could be refined to check specifically for the access error) the popup window is simply closed. This would happen when the user navigates "off-site" because the regular check of the href for the parent window should cause a "Access Error" when the user leaves the site.

Reviewing what I wrote before the following change may help:



<body onload="var ee=setInterval('mainHref = parent.location.href'),2000)">



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum