Go Back   Dynamic Drive Forums > General Coding > JavaScript
Search Dynamic Drive Forums:

Reply
 
Thread Tools Search this Thread
  #1  
Old 10-04-2005, 06:56 PM
ngjeffy ngjeffy is offline
New Comer (less than 5 posts)
 
Join Date: Oct 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default refresh once only when loaded

<html>
<head>
<script language="JavaScript"><!--
function MyReload()
{
window.location.reload();

}
//--></script>
</head>

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

</body>
</html>


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

Thanks
Reply With Quote
  #2  
Old 10-04-2005, 07:04 PM
Twey's Avatar
Twey Twey is offline
Modtoreador
 
Join Date: Jun 2005
Location: 英国
Posts: 11,933
Thanks: 1
Thanked 180 Times in 172 Posts
Blog Entries: 2
Default

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.
__________________
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
Reply With Quote
  #3  
Old 10-04-2005, 07:11 PM
jscheuer1's Avatar
jscheuer1 jscheuer1 is offline
No Kidding?
 
Join Date: Mar 2005
Location: SE PA USA
Posts: 19,000
Thanks: 19
Thanked 1,135 Times in 1,121 Posts
Blog Entries: 3
Default

Code:
<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?
__________________
WWWWWWWWWWWW
- John
________________________

Really Show Your Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate
Reply With Quote
  #4  
Old 10-05-2005, 03:18 AM
ngjeffy ngjeffy is offline
New Comer (less than 5 posts)
 
Join Date: Oct 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.
Reply With Quote
  #5  
Old 10-10-2005, 06:41 AM
jscheuer1's Avatar
jscheuer1 jscheuer1 is offline
No Kidding?
 
Join Date: Mar 2005
Location: SE PA USA
Posts: 19,000
Thanks: 19
Thanked 1,135 Times in 1,121 Posts
Blog Entries: 3
Default

How often do you want to refresh the data in the iframe? In any case you should be able to do something like this:

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script type="text/javascript">
function update(){
setInterval("dataFrame.location.replace('data.htm')",5000)
}
</script>
</head>
<body>
<iframe onload="update();" name="dataFrame" src="data.htm" width="300" height="250" scrolling="auto" frameborder="1"></iframe>
</body>
</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.
__________________
WWWWWWWWWWWW
- John
________________________

Really Show Your Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate
Reply With Quote
  #6  
Old 10-10-2005, 04:39 PM
Twey's Avatar
Twey Twey is offline
Modtoreador
 
Join Date: Jun 2005
Location: 英国
Posts: 11,933
Thanks: 1
Thanked 180 Times in 172 Posts
Blog Entries: 2
Default

May I suggest AJAX? http://developer.mozilla.org/en/docs...etting_Started
__________________
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
Reply With Quote
  #7  
Old 01-03-2007, 05:18 AM
costin costin is offline
New Comer (less than 5 posts)
 
Join Date: Jan 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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">
a=top.hiddenframe.location.href;
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';">
</form>.......
Reply With Quote
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:05 AM.

Home - Contact Us - Archives - Link to DD - Top 

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.