Forum Moderators: coopster

Message Too Old, No Replies

Triggering a Javascript Event with PHP?

         

capulet_x

3:56 am on Apr 16, 2007 (gmt 0)

10+ Year Member



I'm creating a login page but instead of redirection with (Location: http://example.com); I would like to use javascript redirect. Can anyone show me an example or refer me to a tutorial?

eelixduppy

4:21 am on Apr 16, 2007 (gmt 0)



You could just echo something along the lines of the following:

echo '<script type="text/javascript">document.location = "http://www.example.com";</script>';

Should work, however, I would change the header location if you can. This isn't the best way to redirect a page.

capulet_x

4:24 am on Apr 16, 2007 (gmt 0)

10+ Year Member



Thank you for your response.

Can I still adjust the window size using this method?

eelixduppy

4:32 am on Apr 16, 2007 (gmt 0)



Sure; you are just echoing javascript to the browser. It should work as if the javascript was coded into the page itself.

Just note that you may run into issues with those that have javascript disabled.

capulet_x

9:31 pm on Apr 17, 2007 (gmt 0)

10+ Year Member



Thanks Again.