Jump to content



Welcome to KnowledgeSutra - Dear Guest , Please Register here to get Your own website. - Ask a Question / Express Opinion / Reply w/o Sign-Up!
- - - - -

Refresh Page After Back Button Hit


22 replies to this topic

#21 Guest_Jay Edgar_*

  • Guests

Posted 14 October 2011 - 10:34 PM

Here's what I did, which works perfectly. I have a hidden input on my page called reloadValue. This will hold the date value (milliseconds) that's created by the function. If the control is empty when the page loads, the value is loaded into the control. If the control DOES have a value, and that value doesn't match the value just generated, the control is emptied and the page reloads. Note that I'm using jQuery, and telling the body to show in the IF statement. I have set the style of the body to display: none, so that it won't appear to load twice to the user--it just appears when we're all done with the (final) load.

	$(document).ready(function()
	{
		var d = new Date();
		d = d.getTime();
		
		if ($('#reloadValue').val().length == 0)
		{
			$('#reloadValue').val(d);
			$('body').show();
		}
		else
		{
			$('#reloadValue').val('');
			location.reload();
		}
	});

Cheers!

Jay

#22 Guest_niko_*

  • Guests

Posted 02 December 2011 - 01:59 AM

All, I have had a similar issue to what has been described above. It seems Firefox and Opera both share this problem, but I found aseamless result here.

I hope it helps you all as well as it did me, and I apologise if someone else above has already mentioned/linked to it.

Seeyez,

Niko

#23 Guest_Scott_*

  • Guests

Posted 04 December 2011 - 09:44 AM

View PostJay Edgar, on 14 October 2011 - 10:34 PM, said:

Here's what I did, which works perfectly. I have a hidden input on my page called reloadValue. This will hold the date value (milliseconds) that's created by the function. If the control is empty when the page loads, the value is loaded into the control. If the control DOES have a value, and that value doesn't match the value just generated, the control is emptied and the page reloads. Note that I'm using jQuery, and telling the body to show in the IF statement. I have set the style of the body to display: none, so that it won't appear to load twice to the user--it just appears when we're all done with the (final) load.

	$(document).ready(function()
	{
		var d = new Date();
		d = d.getTime();
		
		if ($('#reloadValue').val().length == 0)
		{
			$('#reloadValue').val(d);
			$('body').show();
		}
		else
		{
			$('#reloadValue').val('');
			location.reload();
		}
	});

Cheers!

Jay

This looks like the type of code I need to do what I want to do, I am a programmer, I understand java, but have never formally learned html enough to know how to create a hidden variable, and where things should go, how would I place this into my HTML document?

Thanks in advance.

Scott




Reply to this topic


This post will need approval from a moderator before this post is shown.

  


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users