Forum Moderators: open
<script language="JavaScript"><!--
var isIe = (navigator.appName == "Microsoft Internet Explorer");
function reloadOnceOnly() {
if (isIe) {
window.history.go(0);
}
}
addEvent (window,'load', reloadOnceOnly)
//--></script>
I need to reload this page because IE in 3 of 4 cache settings fails to dsiplay the page properly - only IE cahce setting every time check for a new page works actually
Now it is looping - I want only once that the page reloads and best would be immediately reloadin it
How to do this?
if(window.location.search.indexOf('reload')<0)
window.location.replace(window.location.href+'?reload');
Alternatively, I reckon Mr. Tribble would suggest using the window's name property, since this is preserved - this would leave the address bar untouched.
if(name!='reload')
{
name = 'reload';
window.location.replace(window.location.href);
}
If you want to store data without cookies for a single window, use the navigator object.
In this case you might use something like
function loaded()
{ if (!navigator.fudge) {
navigator.fudge = 1;
location.reload();
}}
Data stored in the navigator object survives page transitions. However, it is not shared between windows.
This works in current versions of Firefox, IE and Opera, but I haven't tested it further.
Kaled.
My DHTML suffers in IE a lot from the caching in IE. I need to relaod a page due to the cahcing in IE to display the page properly!
Is there anyway to avoid meta pragma, expired meta and use javascript
to affect the caching?
What is this actually?
function loaded()
{ if (!navigator.fudge) {
navigator.fudge = 1;
location.reload();
}}
some scripts that maybe usefull for other things
cancell events
function nullify(evt) {
if (!evt) evt = window.event; // define the event object for MSIE
if (evt) {
if (evt.preventDefault) {
evt.preventDefault(); // cancel the default event Opera, Mozilla
evt.stopPropagation(); // this will stop the method bubbling out
}
else {
evt.cancelBubble = false; // stop bubbling on MSIE
evt.returnValue = false; // cancel the default event MSIE
}
}
}
Running the following in IE or Moz yields an alert of "hunh?", while Opera generates a response of "undefined".
window.zum="hunh?";
alert(navigator.zum);
[edited by: Rambo_Tribble at 4:59 pm (utc) on Mar. 9, 2005]
why use the word fudge?
did you test your code?
Fudge is a name I use when I need an identifier to perform some form of cheat.
I did not test the code. I suggested as a basic example of a trick to store information that needs to survive page transitions. I used it when creating some javascript for use in compiled html help (.chm files). Cookies don't work so I had to find an alternative. The basic technique worked, when I tested it, with IE, FF and Opera, however, I only needed it to work with IE due to the application.
Eventually, I dropped the code in favour of an alternative approach.
Kaled.
Update: The original results were an artifact of object persistence: when a property is assigned to the navigator object, it survives even a hard reload of the page.
self.location.replace('URL');
this.location.replace('URL');
window.location.replace('URL');
location.replace('URL');
When you need to preface the location object is when your code is acting on a window other the one the code is executing in. If you did this: var newWin=window.open("","",""); then you could do this: newWin.location.replace('URL');
The replace() method of the location object has been around since NN 3 and IE 4, don't know about when Opera started supporting it, but it has had it since 6, at least.
The method can be called either by the body onload event or by window.onload in a header script.