netfrugal Posted June 8, 2009 Share Posted June 8, 2009 I have 2 files. One file is calling the other file with javascript. This is that I have in the header of index.php: <script type="text/javascript"> httpRequest.open("GET", "/status_page.php", true); // grabbing an integer from this page httpRequest.send(null); httpRequest.onreadystatechange = function() { checkState(); }; function checkState() { if (httpRequest.readyState == 4) { if (httpRequest.status == 200) { var statusCheck = httpRequest.responseText; if (statusCheck == "0"){ window.location = "/logout.php"; } } //End status if } //End readyState If } //End CheckState-Function </script> This works fine. However, I wanted to modify this by not writing the redirect url. I am trying to figure out if I can pass the (window.location="/logout.php") to index.php from the status_page.php When I try that, it simply doesn't work. My guess is the javascript must be written to the page after the main page (index.php) has loaded. And therefore, any extra js will be ignored. But again, I don't want to post the url for everyone to see. Does anyone know of a way to pass a js command after the browser has loaded? Or another work-around? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.