David252a91 0 Report post Posted November 26, 2006 Hi, I was sondering something. Is it possible to do a onLoad property in a body tag that automaticly redirects you to another page? Or onLoad to a function that redirects you to another page? Share this post Link to post Share on other sites
toby 0 Report post Posted November 26, 2006 Why not Meta tags?You could write a function that changes the current window, and stick that in <body onLoad(here)> Share this post Link to post Share on other sites
WeaponX 0 Report post Posted November 26, 2006 Welcome to Xisto.Have you tried something like:<body onload="window.location.href='yoursitehere.com should automatically redirect all your visitors once it reaches the body tag. Share this post Link to post Share on other sites
faulty.lee 0 Report post Posted November 27, 2006 <body onload="window.location.href='yoursitehere.com'; Nothing simpler than that already. By the way, why do you want to do the redirection in the onLoad? If you have nothing you want to show on that page, and want to redirect immediately, put that code in the javascript section at the beginning of the page, that way it doesn't have to wait until the page finished loading. The browser will redirect as soon as it see that code. Good Luck Share this post Link to post Share on other sites
CaptainRon 0 Report post Posted November 27, 2006 In case you want to make sure that every thing in the current page is visible to the user, then in the head section, write a JS to set the window.onload=toSomeFunction; and declare that function with the redirection code. eg.function toSomeFunction(){window.location.href="http://somesite.com/ is what is done at download sites which make u wait for the contents of the window to load first and then start the download. Share this post Link to post Share on other sites
borlafu 0 Report post Posted November 27, 2006 It's not neccesary to declare a new function for doing such a simple operation, the code mentioned before has the same use: <body onload="window.location.href='yoursitehere.com'; And it's sorter, so you will use less bandwidth. Share this post Link to post Share on other sites
TavoxPeru 0 Report post Posted November 27, 2006 As you can see, there are a lot of ways to achieve the same result, i prefer to use winndow.location.href='http://yoursitehere.com;;'>http://yoursitehere.com;;at the begining of the page.Also, you can achieve this same functionallity using a php header function like this:<?phpHeader('Location: http://yoursitehere.com;Best regards, Share this post Link to post Share on other sites
FirefoxRocks 0 Report post Posted November 29, 2006 I've also heard of HTTP redirects which the W3C recommends. It doesn't use META tags and JavaScript. How does that work? Can someone show me an example? Share this post Link to post Share on other sites
borlafu 0 Report post Posted November 29, 2006 @FirefoxRocks:TavoxPeru has just written an example HTTP redirects consists on sending (from the server) a HEADER to the client telling him that the page has changed it's location permanently or just temporaly and the URL to lacate it now.You can see some examples of how to redirect a webpage here:http://www.webconfs.com/154/301-redirects-how-to-redirect-your-website/ Share this post Link to post Share on other sites