Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    New Coder
    Join Date
    Jul 2002
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    domain checker script?

    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?
    __tcserpa___
    uuuuh...what?

  • #2
    Regular Coder
    Join Date
    Jul 2002
    Location
    Western US
    Posts
    169
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #3
    New Coder
    Join Date
    Jul 2002
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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?
    __tcserpa___
    uuuuh...what?

  • #4
    Regular Coder
    Join Date
    Jul 2002
    Location
    Western US
    Posts
    169
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #5
    New Coder
    Join Date
    Jul 2002
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts
    excellent.

    thank you.
    __tcserpa___
    uuuuh...what?

  • #6
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #7
    New Coder
    Join Date
    Jul 2002
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    __tcserpa___
    uuuuh...what?

  • #8
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Totally untested but the following code should do the trick:

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

  • #9
    New Coder
    Join Date
    Jul 2002
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    __tcserpa___
    uuuuh...what?

  • #10
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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:

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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •