faqts : Computers : Programming : Languages : JavaScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

21 of 42 people (50%) answered Yes
Recently 3 of 10 people (30%) answered Yes

Entry

How do i capture the Reload event in Javascript and use it to perform certain tasks (like changing URL) before the page gets loaded again?

Apr 4th, 2008 20:47
ha mo, Sheana blogs, Colin Fraser, arunangshu chakrabarty,


You cannot capture the reload event, but you can change the history of 
the browser and you can replace the current history url.
<script language="JavaScript"><!--
 if (document.images)
     location.replace('http://www.thisplace.com.au/thatpage.htm');
 else
     location.href = 'thatpage.htm';
 //--></script>
Opera will only use the replace() with an absolute URL's. Also, the 
document.images test is applied because older browsers do not use the 
replace() method.
http://articlesfor4.blogspot.com
http://islandsofworld.blogspot.com/
http://worldsbestbeaches.blogspot.com/
http://top-honeymoondestinations.blogspot.com/
http://topweddingguide.blogspot.com/
http://www.businessian.com
http://www.computerstan.com
http://www.financestan.com
http://www.healthstan.com
http://www.internetstan.com
http://www.moneyenews.com
http://www.technologystan.com
http://www.zobab.com
http://www.healthinhealth.com