SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Member
    Join Date
    Nov 2001
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question 24 Hour Pop Code

    The following is the code for webhitsdirect's pop under campaign. It currently pops on every page view. I was wondering if somebody could write something that would make this pop every 24 hours instead of every page view. (Sorry if this is the wrong forum)

    Here is the code:
    <!--Begin WHD Code-->
    <script language="javascript">whdAffiliate=128</script>
    <script language="javascript" src="http://www.webhitsdirect.com/whd.js">
    </script>
    <!--End WHD Code-->

  2. #2
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it is possible but i cant think right now so i gave you a long winded version kindof

    PHP Code:

    <html>
    <
    body>
    <
    script>

    var 
    scripts = new Array;
    scripts[0]  = 'java.js';
    scripts[1]  = '';
    scripts[2]  = '';

    function 
    time_date()
    {
    var 
    d=new Date()

    var 
    weekday    = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
    var 
    month    = new Array("Janary","February","March","April","May","June","July","August","September","October","November","December")
    var 
    getIT    = new Array('<sup>st</sup>''<sup>nd</sup>''<sup>rd</sup>''<sup>th</sup>');

    if    (
    d.getDate() == || d.getDate() == 21 || d.getDate() == 31)
        
    th getIT[0];
    else if (
    d.getDate() == || d.getDate() == 22 || d.getDate() == 32)
        
    th getIT[1];
    else if (
    d.getDate() == || d.getDate() == 23 || d.getDate() == 33)
        
    th getIT[2];
    else
        
    th getIT[3];

    '';
    w+= d.getHours() + ':';
    w+= d.getMinutes() + ':';
    w+= d.getSeconds() + '...';
    w+= weekday[d.getDay()] + ", ";
    w+= d.getDate();
    w+= th " "
    w+= month[d.getMonth()] + " ";
    w+= d.getFullYear();
    ale()
    return 
    w;
    }

    function 
    ale()
    {
        var 
    date      = new Date();
        var 
    hours     date.getHours();

        if (
    hours==24)alert(hours);
    }



    setInterval("document.all.timing.innerHTML=time_date();document.all.scrip_T.innerHTML='<scr' + 'ipt type=\"javascript\" src=\"' + scripts[0] + '\"></scr' + 'ipt>';",1)

    </script>

    <div name="scrip_T" id="scrip_T" ></div>
    <div name="timing" id="timing" style="background-color: black;color:white;"><script type="javascript">document.write (w);</script></div>

    </body>
    </html> 
    play about with this bit

    PHP Code:


    setInterval
    ("document.all.timing.innerHTML=time_date();document.all.scrip_T.innerHTML='<scr' + 'ipt type=\"javascript\" src=\"' + scripts[0] + '\"></scr' + 'ipt>';",1
    what i tried doing about was inserting the javasript using innerHTML, but the corret method should be like this or similar

    document.getelementbyTagName['script'].src = 'myjavascript.js'

    let me know if you can get it to work

  3. #3
    SitePoint Member
    Join Date
    Nov 2001
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I shoud have also stated that my programming knowledge is basically nonexistant. Looking over the code, it doesn't look like the specific code for the pop under is incorporated. Is there anyway you can work that into your code?

  4. #4
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    lol, i wish i opened the javascript file before, as i thought you were accessing an external javascript file lol.

    PHP Code:
    <html>
    <
    body>
    <
    script>

    affiliate_number 128;
        function 
    time_date()
        {
            var 
    d=new Date()
            if (
    d.getHours() == 24 || d.getHours() == 0popup();
        }
        function 
    popup()
        {
            var 
    randomnumber=Math.floor(Math.random()*10000);
            
    url 'http://www.webhitsdirect.com/whd.php?rndNum=' randomnumber '&affiliate=' affiliate_number;
            
    window.open(url'mywindow''width=650,height=550,location=no,toolbar=no,menubar=no,scrollbars=yes,resizable=yes');
            
    window.focus()
        }
    time_date()
    </script>
    </body>
    </html> 
    Last edited by Andrew-J2000; Apr 27, 2002 at 14:35.

  5. #5
    SitePoint Member
    Join Date
    Nov 2001
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I just copy pasted that into my HTML under the <body> tag and no window popped up. Is that all I am supposed to do?

  6. #6
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes just change this line

    if (d.getHours() == 24 || d.getHours() == 0) popup();

    ie 24 to the current hour and it will always display a popup for that hour

  7. #7
    SitePoint Member
    Join Date
    Nov 2001
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh, I see how it works. So it will pop only during a certain hour. Thanks for your help, but it isn't exactly what I was looking for. Maybe I didn't explain it well enough. Here is the situation. I want to put the code on all of the pages within my site. If a person is visiting for the first time, they will see the pop, but if the go to another page on my site the same day, they won't see a pop. This also makes sure no matter what page the person enters from they will get a pop just once for that day. Maybe this clears things up?

  8. #8
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    http://www.webmasterbase.com/article/648/23

    theres an example there

    just change there dopopup function to

    PHP Code:
    function doPopup()
    {
        var 
    ezine getCookie('popupShown');
        
    setCookie('popupShown''true''''');
        
        if(
    ezine == '')
        {
            
    time_date()
        }

    include the code above as well

  9. #9
    SitePoint Member
    Join Date
    Nov 2001
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There was no DoPopup function previously...

  10. #10
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    using the code from this example if you checked it, it would have the dopopup code

    http://www.webmasterbase.com/article/648/23


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
  •