View Full Version : refresh once only when loaded

10-04-2005, 05:56 PM
<script language="JavaScript"><!--
function MyReload()


<Body onload="MyReload()">
Heloo .. how r u ?


**i tried this but the page always continuing refresh, any other ways to refresh it once only when loaded?


10-04-2005, 06:04 PM
The easiest way to do this is create a seperate page. It's also possible to pass a GET variable to the page, then retrieve it via ECMAScript (i.e. "index.htm?firsttime=no"). If you search the archives, you'll find a few examples of this.

10-04-2005, 06:11 PM
<body onload="if (location.href.indexOf('reload')==-1) {location.replace(location.href+'?reload')}">As long as the url of the original page doesn't contain the string 'reload' this will do the trick. However, often this type of reload does not accomplish what you imagine it might. I take it you are trying to solve some problem with the page that is also solved if you hit the refresh button. If so, a better approach is to find some other solution to that problem in the first place, what is it?

10-05-2005, 02:18 AM
oh. i am using a iframe inside a html. however, that iframe is using MySQL to get data. I do not want to refresh my html. i just wanna to refresh the data in the iframe as it is goin to retrieve data from database.

10-10-2005, 05:41 AM
How often do you want to refresh the data in the iframe? In any case you should be able to do something like this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script type="text/javascript">
function update(){
<iframe onload="update();" name="dataFrame" src="data.htm" width="300" height="250" scrolling="auto" frameborder="1"></iframe>
</html>5000 is how often (in milliseconds) that the iframe named 'dataFrame' will update with the page 'data.htm' which could be the page that gets its data from the database.

10-10-2005, 03:39 PM
May I suggest AJAX? http://developer.mozilla.org/en/docs/AJAX:Getting_Started

01-03-2007, 05:18 AM
Heres what i did to refresh a page once when visitor click back browser button:
1. framset with 2 pages. created 1 mainframe page and 2 blank hiddenframe pages.
frameset parts: ......<frame src="hiddenframe1 url" name="hiddenframe" id="hiddenframe">......
2. mainframe parts:
<body><script language="javascript">
if (a.match('hiddenframe2 url')){top.mainframe.location='mainframe url';top.hiddenframe.location='hiddenframe1 url'}</script>
<form......<input type="submit".......onclick="top.hiddenframe.location='hiddenframe2 url';">