Jump to content

Passing a js command after the browser has loaded?


netfrugal

Recommended Posts

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?

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.