December 28, 1999 - The onresize-reload Trap
December 28, 1999 The onresize-reload Trap Tips: December 1999
Yehuda Shiran, Ph.D.
|
function redo() {
window.location.reload();
}
if (NS4) window.onresize = redo;
The preceding code segment worked fine -- until Netscape introduced Navigator 4.04. On Navigator 4.04, a resize event occurs when the page loads. Our redo()
function then reloads the page, and a resize event occurs (again). This process traps our page in a loop -- the page reloads continuously. We solved the problem by setting the window.onresize
event handler one second after the page loads:
function init() {
setTimeout("window.onresize = redo", 1000);
}
function redo() {
window.location.reload();
}
if (style) {
.
.
.
if (NS4) window.onload = init;
}
Learn more about how we used this code in Column 16, Dynamic Tooltips.