Results 1 to 7 of 7

Thread: refresh once only when loaded

  1. #1
    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

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    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!

  3. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    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?
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  4. #4
    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.

  5. #5
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    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.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  6. #6
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    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!

  7. #7
    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>.......

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •