frostis21
08-20-2010, 11:17 AM
Hi all -
I´ve added a randomized header script to my page :
www.escalamadrid.com/test_1/ (http://escalamadrid.com/test_1/)
The code is working correctly but due to the page load time - there is a delay in the new header image appearing when switching pages.
Here is the Javascript:
// JavaScript Document
var chosenImage=new Array();
chosenImage[0]="header_01.jpg";
chosenImage[1]="header_02.jpg";
etc....
var chosenAltCopy=new Array();
chosenAltCopy[0]="escalar madrid";
chosenAltCopy[1]="escalar madrid";
etc....
var getRan=Math.floor(Math.random()*chosenImage.length);
function randomImage()
{
document.getElementById('randomImage').setAttribute ('src', 'Site/images/header/'+chosenImage[getRan]);
document.getElementById('randomImage').setAttribute ('alt', chosenAltCopy[getRan]);
}
The function is called from the html page using the following:
<body onload="randomImage()";>
...so my question is - Is there anyway to avoid this delay or will i be forced to grin and bear it due to the weight of the pages i´m loading in.
Any ideas greatly appreciated!
I´ve added a randomized header script to my page :
www.escalamadrid.com/test_1/ (http://escalamadrid.com/test_1/)
The code is working correctly but due to the page load time - there is a delay in the new header image appearing when switching pages.
Here is the Javascript:
// JavaScript Document
var chosenImage=new Array();
chosenImage[0]="header_01.jpg";
chosenImage[1]="header_02.jpg";
etc....
var chosenAltCopy=new Array();
chosenAltCopy[0]="escalar madrid";
chosenAltCopy[1]="escalar madrid";
etc....
var getRan=Math.floor(Math.random()*chosenImage.length);
function randomImage()
{
document.getElementById('randomImage').setAttribute ('src', 'Site/images/header/'+chosenImage[getRan]);
document.getElementById('randomImage').setAttribute ('alt', chosenAltCopy[getRan]);
}
The function is called from the html page using the following:
<body onload="randomImage()";>
...so my question is - Is there anyway to avoid this delay or will i be forced to grin and bear it due to the weight of the pages i´m loading in.
Any ideas greatly appreciated!