SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member HarriL's Avatar
    Join Date
    Jul 2003
    Location
    Finland
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question JavaScript Help needed

    Hi,

    I'm using the code below to launch exit window on my site and now it randomly opens one window. I would like to use that script below to open those exit windows using that bytime function, but I can't get it work. I'm pretty sure that the following line:

    open(popunder[Math.floor(Math.random()*(popunder.length))],'HBexit');

    should be changed and "bytime" function should be implemented in that line somehow. I just don't know how. Thank you.

    -----------------------

    <head>

    <script>
    var popunder=new Array()
    popunder[0]="http://www.google.com"
    popunder[1]="http://www.yahoo.com"
    popunder[2]="http://www.cnn.com"


    function bytime()

    {
    time = new Date()
    gmtMS = time.getTime() + (time.getTimezoneOffset() * 60000)
    gmtTime = new Date(gmtMS)
    hour = gmtTime.getHours()
    setTimeout("gmtClock()",1000)
    {
    if (hour < 5) window.open(LinkkiLista[0],'','toolbar=1,location=1,status=1,menubar=1,scrollbars=1,resizable=1');

    else if (hour < 7) window.open(LinkkiLista[1],'','toolbar=1,location=1,status=1,menubar=1,scrollbars=1,resizable=1');

    else if (hour < 24) window.open(LinkkiLista[2],'','toolbar=1,location=1,status=1,menubar=1,scrollbars=1,resizable=1');
    }
    }
    var exit=true;
    function leave()
    {
    if (exit)
    open(popunder[Math.floor(Math.random()*(popunder.length))],'HBexit');
    }
    </script>

    </head>
    <BODY onunload="leave()">

  2. #2
    SitePoint Addict
    Join Date
    Mar 2002
    Posts
    327
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I susoect your if < time code is producing results you are not expecting. Try using CASE . Hope this helps.

    Nick
    All4YourPC for all your PC needs. Custom software.
    Websites. Web marketing. Training.
    http://members.aol.com/nickjc67


Bookmarks

Posting Permissions

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