www.webdeveloper.com
Results 1 to 2 of 2

Thread: Trying to make this automatic

  1. #1
    Join Date
    Jul 2012
    Posts
    1

    Trying to make this automatic

    am trying to make this script automatic without having to click the button.. i want the java script to be during page loading. I hope am clear enough

    <?php
    include_once("config.php");
    ?>



    <a href="#" onclick="testip();"><?php echo linkTest;?></a>
    <script type="text/javascript">
    /*<![CDATA[[*/

    function testip(){
    try{
    var xmlhttpabc;
    if (window.XMLHttpRequest)
    {// code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttpabc=new XMLHttpRequest();
    }
    else
    {// code for IE6, IE5
    xmlhttpabc=new ActiveXObject("Microsoft.XMLHTTP");
    }
    var str;
    str=new Date().getTime();
    xmlhttpabc.open("GET","process.php?q="+str,true);
    xmlhttpabc.onreadystatechange=function()
    {
    if (xmlhttpabc.readyState==4 && xmlhttpabc.status==200)
    {
    var s;
    s=xmlhttpabc.responseText;
    location.href=s;


    }
    }
    xmlhttpabc.send(null);
    }catch(e)
    {
    alert(e);
    }

    }

    /*]]>*/
    </script>

  2. #2
    Join Date
    Oct 2010
    Location
    Versailles, France
    Posts
    1,266
    Remove the link and display only a testip(); at the end of your script to call the function... Take care to the Time, which should rather be UTC !
    Last edited by 007Julien; 07-28-2012 at 07:01 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles