Ok, I have my html page called test.htm, my external javascript file called images.js and one of my images called banner_02.gif. They are all in the same directory.
I am doing this so I only need to change the addresses of several images from one file that will then be used across several pages.
This is my html code (don't mind the rest, just my variable imSRC = banner:
<head>
</head>
<body>
<script language="JavaScript" src="images.js">
function makeIm() {
NS4=(document.layers);
IE4=(document.all);
scaleWidth = true;
scaleHeight = true;
imSRC = banner;
if (NS4) {
origWidth = innerWidth;
origHeight = innerHeight;}
function reDo() {
if (innerWidth != origWidth || innerHeight != origHeight)
location.reload();}
if (NS4) onresize = reDo;
if (IE4) onresize = reDoIE;
function reDoIE(){
imBG.width = document.body.clientWidth;
imBG.height = document.body.clientHeight;}
winWid = (NS4) ? innerWidth : document.body.clientWidth;
winHgt = (NS4) ? innerHeight : document.body.clientHeight;
imStr = "
+ " style='position:absolute;left:0;top:0;z-index:-1'>"
+ "<img name='imBG' border='0' src="+imSRC;
if (scaleWidth) imStr += " width="+winWid;
if (scaleHeight) imStr += " height="+winHgt;
imStr += ">
";
document.write(imStr);}
makeIm();
</script>
</body>
------------------------
Now, I aren't sure how I should write images.js
This is all I have:
var banner = "banner_02.gif";
--------------------------
I know that test.htm is reaching images.js, because when I remove script src="images.js" I get an error with the variable banner.
How do I write the external javascript file?
Regards
JRoberts
I am doing this so I only need to change the addresses of several images from one file that will then be used across several pages.
This is my html code (don't mind the rest, just my variable imSRC = banner:
<head>
</head>
<body>
<script language="JavaScript" src="images.js">
function makeIm() {
NS4=(document.layers);
IE4=(document.all);
scaleWidth = true;
scaleHeight = true;
imSRC = banner;
if (NS4) {
origWidth = innerWidth;
origHeight = innerHeight;}
function reDo() {
if (innerWidth != origWidth || innerHeight != origHeight)
location.reload();}
if (NS4) onresize = reDo;
if (IE4) onresize = reDoIE;
function reDoIE(){
imBG.width = document.body.clientWidth;
imBG.height = document.body.clientHeight;}
winWid = (NS4) ? innerWidth : document.body.clientWidth;
winHgt = (NS4) ? innerHeight : document.body.clientHeight;
imStr = "
+ " style='position:absolute;left:0;top:0;z-index:-1'>"
+ "<img name='imBG' border='0' src="+imSRC;
if (scaleWidth) imStr += " width="+winWid;
if (scaleHeight) imStr += " height="+winHgt;
imStr += ">
";
document.write(imStr);}
makeIm();
</script>
</body>
------------------------
Now, I aren't sure how I should write images.js
This is all I have:
var banner = "banner_02.gif";
--------------------------
I know that test.htm is reaching images.js, because when I remove script src="images.js" I get an error with the variable banner.
How do I write the external javascript file?
Regards
JRoberts