View Full Version : Unable to prevent image reload

07-22-2002, 07:26 PM
Unable to prevent image reload.

I've read that losing dynamic content when resizing NN4 browser is a common problem, and the only way to solve is a page reload. (Also read that scrollbars are the real problem.)

Is this true? Any suggestions to avoid page reload?

Specifically, I have random images and the one dispalyed is lost upon window resize. If I use a reload, a new image is placed because of the random generator doing its job. However, on a resize I want to keep the same image displayed, maybe by avoiding a reload?

I have tried cookies and also frames but it's still a problem.

Any help appreciated!

07-22-2002, 08:50 PM
you really should stick in the same thread unless your issue changes a lot. for other readers, the original thread is at:


have you tried using location.search?
put this in your <head>, after you have loaded the picture arrays (topPic and botPic).

<script language=javascript>
window.onresize = "window.location.reload()"
imgCt = topPic.length
if (window.location.search) {
randomNum = window.location.search.substr(1)
//gets randomNum from URL bar.
randomNum = Math.floor (Math.random() * imgCt)
window.location.search="?" + randomNum
//automatically reloads once and puts randomNum in URL bar
document.topPicture.src = topPic[randomNum]
document.botPicture.src = botPic[randomNum]

any luck? :thumbsup:

07-22-2002, 11:37 PM
Tried it and the images don't appear at all. Even modifications don't work.

Thanks Neil and everyone who replied, but it just seems impossible.

07-23-2002, 01:21 AM
<script type="text/javascript">

var img_dir = 'http://www.noeticart.com/clipart/';
var randImg = new Array();
randImg[0] = 'lampc.gif';
randImg[1] = 'paintcanc.gif';
randImg[2] = 'tellyc.gif';
randImg[3] = 'mailboxc.gif';
randImg[4] = 'plantc.gif';

var whichImg = randImg[Math.floor(Math.random() * randImg.length)];

var imgHTML = (location.search) ?
'<img src="' + img_dir + unescape(location.search.substring(1)) + '">' :
'<img src="' + img_dir + whichImg + '">';

if (document.layers) {
origWidth = innerWidth;
origHeight = innerHeight;
onresize = function() {
if (innerWidth != origWidth || innerHeight != origHeight)
(location.href.indexOf('?') == -1) ?
location += '?' + whichImg : location.reload();

<script type="text/javascript">
if (document.layers) document.write('<layer left="30%" top="20%">'+imgHTML+'</layer>');
else document.write('<div style="position:absolute;left:30%;top:20%;">'+imgHTML+'</div>');

just a note: this -

window.onresize = "window.location.reload()"

..is incorrect syntax.

onresize = function() {

07-23-2002, 07:33 PM
Thanks, Adi, but after trying and modifying a while it produces no image or says "undefined".

I'm sure the code works when integrated with my page eventually, and appreciate your help. It's just beyond my coding abilities at the moment. I'll keep at it, and eventually will master all.

07-23-2002, 07:46 PM
Works here. *Simple script*. :confused:

I'm guessing 'layers' - but just guessing.

07-23-2002, 09:16 PM

why don't you stick your whole page up here - in an attachment if its very big. this problem is getting quite frustrating for me cos whenever i test anything - it works!

it must be the way you're integrating the scripts we're suggesting into your page, cos on their own they usually work fine.

post your html page (or email it me nc@flashmail.com if you don't want it open on this forum), then i (and others) can try and find out what the problem really is. :thumbsup:

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum