PDA

View Full Version : marquee the direction


gencoglu27
03-16-2006, 03:39 AM
Hi,How can I change the direction so that the background image should move left or right...The direction in the The code below is upward
Thanks a lot


<body background="sky5.jpg">

<script>
var howQuick = 1;

var beIE = document.all?true:false;
var iWhere = 0;

function scrollBackGround(){
if (beIE){
iWhere = iWhere - 1;
if (iWhere > 1000000) iWhere = 1;
document.body.style.backgroundPosition = "0 " + iWhere;
window.setTimeout("scrollBackGround()",howQuick);
}
}

scrollBackGround();

</script>

Random
03-16-2006, 06:01 AM
Change this:
document.body.style.backgroundPosition = "0 " + iWhere;
To be this:
document.body.style.backgroundPosition = iWhere + " 0";

The backgroundPosition style controls both horizontal and vertical background positions. You'll notice that what you have now, is the first (horizontal) value set to 0, and the second (vertical) value is set to iWhere. To fix it, make the first (horizontal) value equal to iWhere, and the second (vertical) value equal to 0.

gencoglu27
03-16-2006, 08:00 AM
Thanks Random,
you solved the problem..You are great...
My other question is that can't we use imag tag other than here ?<body background="sky5.jpg">
I mean , can we get the "background image "using getElementById()..?
thanks

Random
03-16-2006, 06:49 PM
No, you cannot get the background image using getElementById(). The background image of a page is a property of the <body> tag, not an element within the <body> tag.

Are you wanting to return the actual background image, or just the name of the image? If you want just the name of the image, you may be able to retreive it like this:
var bgImageName = document.body.style.background-image;
That said, I have not used the above technique, so I'm not sure if it will work or not.