How do I delay a javascript action within php?

Discussion in 'PHP' started by netnuta, Oct 25, 2008.

  1. #1
    Hi there,

    I have a site that uses the cpa lead gateway system that is activated when a user clicks through to a page.php to view a embeded video. I would like to delay the script from activating for a set time that I choose (e.g. 60 seconds or more).

    The code at present is placed at the top of the video.php before the first <?php tag.

    The code examlpe is:

    <script src="http://www.cpalead.com/gateway.php?pub=????" language="JavaScript" type="text/javascript"></script>

    Is there a simple way to add a delay function to this script, if so can you show me an example with the above script included?

    Many thank's for taking the time to help on this problem!
     
    netnuta, Oct 25, 2008 IP
  2. Kyosys

    Kyosys Peon

    Messages:
    226
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #2
    that would be javascript, and not PHP. Php is serverside, you can't stop this unless you use sleep() or something, but that's not what you want
     
    Kyosys, Oct 25, 2008 IP
  3. SEOAnalytic.com

    SEOAnalytic.com Member

    Messages:
    106
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    26
    #3
    I don't know if that would work, but here's a solution.
    Put these div tags in your head tags. <div id="script_goes_here"></div>
    then after these div tags add the js code
    
    <script type="text/javascript">
    function loadJS() {
    document.getElementById('script_goes_here').innerHTML='<script src="http://www.cpalead.com/gateway.php?pub=????" language="JavaScript" type="text/javascript"></script>';
    }
    setTimeout('loadJS()',60000);
    </script>
    
    Code (markup):
     
    SEOAnalytic.com, Oct 26, 2008 IP