ad timeing script need help

Discussion in 'JavaScript' started by nicky s, Nov 5, 2009.

  1. #1
    hey i am using the script below on my site if you look here you can see what it dose filmfast.co.uk/s1e1.php

    now what i want it to do is when some one clicks the ad it loads the video striaght away and cancles the timer if that makes any sence

    can it be done ?

    <div align="center" class="style29"><div id="mycontent" style="display:none">
                <script type="text/javascript"><!--
    google_ad_client = "pub-9670252957648140";
    /* 250x250, created 21/09/09 */
    google_ad_slot = "8877296912";
    google_ad_width = 250;
    google_ad_height = 250;
    //-->
    </script>
                <script type="text/javascript"
    src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    </script>
                <br />
                <br />
                <img src="loading.gif" width="16" height="16"><br />
                <span id="countdown">Loading...</span><br />
                <strong><span class="style30">Click the Ad to Watch Now!</span></strong><span class="style30"></span><br />
                </div>
                
                <script type="text/javascript">
    function countdown(count)
    {
    document.getElementById("countdown").innerHTML="Video Loading... <b>"+count+"</b> seconds remaining...";
    count-=1;
    	if(count>=0)
    	setTimeout("countdown("+count+")",1000);
    
    	else
    	custom();
    }
    
    function custom()
    {
    	document.getElementById("mycontent").innerHTML='<object width="640" height="350"><param name="movie" value="http://www.megavideo.com/v/FFNB0V5024cee052d28ba3fde653170fc3901f65"></param><param name="allowFullScreen" value="true"></param><embed src="http://www.megavideo.com/v/FFNB0V5024cee052d28ba3fde653170fc3901f65" type="application/x-shockwave-flash" allowfullscreen="true" width="640" height="350"></embed></object>';
    }
    
    document.getElementById("mycontent").style.display="block";
    countdown(10);
    </script>
                <br />
              </div>
    Code (markup):

     
    nicky s, Nov 5, 2009 IP
  2. brealmz

    brealmz Well-Known Member

    Messages:
    335
    Likes Received:
    24
    Best Answers:
    3
    Trophy Points:
    138
    #2
    try place your ad inside a container width id then listen for its click event.
    it was something like this but not sure will work. but maybe worth a try
    
       document.getElementById('adcontainer').onclick = function(){
                                                        clearTimeout(createdtimeout);  //assign your setTimeout to global variable createdtimeout
                                                        custom();
                                                     };
    
    Code (markup):
     
    brealmz, Nov 5, 2009 IP
  3. nicky s

    nicky s Peon

    Messages:
    199
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I dont really now what im doing with javascrit any chace you could stick it into the code above. Also by doing this will the click still count for google ads i mean if i do this the click will still earn me money or not??
     
    nicky s, Nov 5, 2009 IP