Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    Regular Coder
    Join Date
    Apr 2003
    Location
    Seoul, Korea
    Posts
    329
    Thanks
    0
    Thanked 0 Times in 0 Posts

    automatical reload with history.go(-1)

    <INPUT TYPE="button" VALUE="Click here to reload" onClick="window.location.reload()">

    The above javascript button is for reloading.
    If a user click the button, the page will be reloaded.

    Now this time,
    I like to make the page to be being automatical reloaded.

    When the page is opened again by the code "history.go(-1),
    I like to make the page to be being automatically reloaded without any click for reload button like the above javascript button.

    Is that possible?

  • #2
    Master Coder
    Join Date
    Feb 2003
    Location
    UmeŚ, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    Hm, have you tried to set a variable on the window first, then go back, then look for that variable? I'm not sure it works, but I've used something like it before, so it may well do.
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #3
    Regular Coder
    Join Date
    Apr 2003
    Location
    Seoul, Korea
    Posts
    329
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for your suggestion.

    How can I set a variable on the window first?

  • #4
    Master Coder
    Join Date
    Feb 2003
    Location
    UmeŚ, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    Try window.variableName=true;
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #5
    Regular Coder
    Join Date
    Apr 2003
    Location
    Seoul, Korea
    Posts
    329
    Thanks
    0
    Thanked 0 Times in 0 Posts
    <javascript>
    window.reflesh=true;
    </javascript>


    Like the above?

    anyway I put it in the page.
    I think now I have to make an automatical call the variable "window.reflesh".

    Am I on the track?

    and now how can I make the automatical call?

  • #6
    Master Coder
    Join Date
    Feb 2003
    Location
    UmeŚ, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    Code:
    if(typeof window.refresh!='undefined' && window.refresh){
        window.refresh=false;
        location.reload();
    }
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #7
    Regular Coder
    Join Date
    Apr 2003
    Location
    Seoul, Korea
    Posts
    329
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    <script>
    	window.reflesh=true;
    	if(typeof window.refresh!='undefined' && window.refresh){
        	window.refresh=false;
        	location.reload();
    		}
    </script>
    I have put the above code in the page.
    But It seems not to be being reloaded as I test it.

    Do you see something wrong in my code?

  • #8
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,074
    Thanks
    0
    Thanked 256 Times in 252 Posts
    so you want it to auto reload once?

    <INPUT TYPE="button" VALUE="Back" onClick="window.name='autoreload';history.go(-1)">

    then in the page opened by history.go(-1):

    Code:
    function autoReload(){
      if (window.name=='autoreload') {
         location.reload();
         window.name='';
      }
    }
    ...
    <body onload="autoReload()">
    The problem here is if the user chooses to use the browser's BACK button instead of yours.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________


  •  

    Posting Permissions

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