View Full Version : Using body onload to redirect using images

07-30-2006, 10:10 AM
Hi - I am using a CMS. Through this I can post images to the index page of my site. What I want to know is it possible to add an body onload tag to an image field so that when the image displays it autoredirects to a different page.

At the moment I've tried using this:

<body onload="window.location.replace('http://www.testsite.com')">

But it redirects in my admin page rather than the main index page.

Basically I want people when they connect to index.php to be automatically redirected to a different page, but I can't actually physically edit the source of the script, so am wondering if there is an easy way of adding this code to a field in the admin page that will load it into the index page, and I figured that doing it through an image might be the easiest thing to do.

I want to remotely change the page, so think it's something in the 'window.location' tag that needs changing, perhaps to 'window.location.href'?

Any suggestions appreciated.

07-30-2006, 04:00 PM
<body onload="window.location.href='http://www.testsite.com'">

07-30-2006, 04:11 PM
Why Not To Use A CMS. :)