Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reload function

Status
Not open for further replies.

zeert2002

Programmer
Sep 26, 2007
13
0
0
US
Hi, I really need help with this weird problem with the reload function.
I'm trying to reload a page if that page is visited. Here is my code:

Code:
if(window.name=="TEST"){ window.name=""; } else{ window.name="TEST"; javascript:location.reload(true); }

My problem is this. In firefox, it works fine, but in ie, it reloads in an infinite loop. What am I doing wrong? Thanks.
 
Check Firefox's error console to see if it's working "fine" because of a glaring error in your code.

What do you want to accomplish with this? Every time the page loads, you start fresh. This means that if you set the window.name property, it will revert to the original as soon as the page reloads.

Lee
 
My firefox error console did not give any errors. This is so weird. I'm tryin to reload, not refresh, the page on visit. Thanks.
 
What do you think "reload" and "refresh" mean? If you load the page a second time, you make the request to the web server, which sends you the same HTML that you got the first time.

Lee
 
Hi

zeert2002 said:
Code:
if(window.name=="TEST"){ window.name=""; } else{ window.name="TEST"; [s][red]javascript:[/red][/s]location.reload(true); }
Remove the [tt]javascript:[/tt] pseudo-protocol. Without that, it works for me in Mozillas, Opera, Safari and Explorer 6. But note that Microsoft sometimes corrects bugs by disabling features. Are you sure your Explorer is able to set the [tt]window.name[/tt] from JavaScript code ?


Feherke.
 
Hmm, I've tried removing it and it still does not work on my ie 6. Well, I don't think explorer is setting the window.name correctly. Thanks for the reply.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top