PDA

View Full Version : background image stretch- how to modify this script?



starchild
10-09-2003, 02:12 AM
hi there,

I found this script that allows a background image to stretch according to the size of the page - how do i integrate this into OSCMAX_1.5.....i'm assuming it goes into main_page.tpl, but how I'm not sure. Anyone any ideas?

here's the script------------>


<html>
<HEAD>
<SCRIPT LANGUAGE="JavaScript1.2">
<!--
NS4 = (document.layers);
IE4 = (document.all);

scaleWidth = true;
scaleHeight = true;
imSRC = "background.jpg";

if (NS4) window.onload = setResize;

function setResize(){
setTimeout("window.onresize=reDo;",500);
}

function reDo(){
window.location.reload()
}

if (IE4) window.onresize = reDoIE;

function reDoIE(){
imBG.width = document.body.clientWidth;
// imBG.height = document.body.clientHeight;
}

function makeIm() {

winWid = (NS4) ? innerWidth : document.body.clientWidth;
// winHgt = (NS4) ? innerHeight : document.body.clientHeight;

imStr = "<DIV ID=elBGim"
+ " 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 += "></DIV>";

document.write(imStr);

}
//-->
</SCRIPT>
</HEAD>

<BODY MARGINHEIGHT=0 MARGINWIDTH=0>
<SCRIPT LANGUAGE="JavaScript1.2">
<!--
makeIm();
//-->
</SCRIPT>

<body>
</body>
</html>



<---------------------end of script

Cheers, Tim

starchild
10-10-2003, 04:34 AM
i edited the original post's script with a simpler one - but still can't integrate it. Any one any ideas?

tim

michael_s
10-10-2003, 07:34 AM
I think you just put this code in the <head> section:


<SCRIPT LANGUAGE="JavaScript1.2">
<!--
NS4 = (document.layers);
IE4 = (document.all);

scaleWidth = true;
scaleHeight = true;
imSRC = "background.jpg";

if (NS4) window.onload = setResize;

function setResize(){
setTimeout("window.onresize=reDo;",500);
}

function reDo(){
window.location.reload()
}

if (IE4) window.onresize = reDoIE;

function reDoIE(){
imBG.width = document.body.clientWidth;
// imBG.height = document.body.clientHeight;
}

function makeIm() {

winWid = (NS4) ? innerWidth : document.body.clientWidth;
// winHgt = (NS4) ? innerHeight : document.body.clientHeight;

imStr = "<DIV ID=elBGim"
+ " 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 += "></DIV>";

document.write(imStr);

}
//-->
</SCRIPT>


And this code in the body section, where you want the image to appear:

<SCRIPT LANGUAGE="JavaScript1.2">
<!--
makeIm();
//-->
</SCRIPT>

I have not tried it, but it seems pretty straightforward.

starchild
10-11-2003, 05:14 AM
thanks msasek.