...

View Full Version : scrolling image problems



danl linehan
05-26-2004, 08:20 PM
not sure exactly what it is called, but i've put a scrolling image in the bottom corner of this site:

http://www.kjdenhert.com/new/simon/index.html

it's the first time i've tried to use this feature, so i'm not at all familiar with the way it actually works (i borrowed to code)... i've been futsing with the script trying to get the image to scroll on the bottom LEFT corner rather than the right corner, but i can't figure out how to do it...

my script is as follows... any help would be greatly appreciated... thank you!!!


<script language="JavaScript"><!--
function DOMGetElement(o) {
if (document.getElementById) return document.getElementById(o);
else if (document.all) return document.all[o];
else if (document.layers) return document.layers[o];
return null;
}

function DOMWindowGetXOffset() {
if (document.all) return document.body.scrollLeft;
else if (document.getElementById) return window.pageXOffset;
else if (document.layers) return window.pageXOffset;
}

function DOMWindowGetYOffset() {
if (document.all) return document.body.scrollTop;
else if (document.getElementById) return window.pageYOffset;
else if (document.layers) return window.pageYOffset;
}

function DOMElementSetTopPos(o,val) {
if (document.getElementById) o.style.top = val;
else if (document.all) o.style.top = val;
else if (document.layers) o.pageY = val;
}

function DOMElementSetLeftPos(o,val) {
if (document.getElementById) o.style.left = val;
else if (document.all) o.style.left = val;
else if (document.layers) o.pageX = val;
}

function DOMWindowGetInnerWidth() {
if (document.all) return document.body.clientWidth;
else if (document.getElementById) return window.innerWidth;
else if (document.layers) return window.innerWidth;
}

function DOMWindowGetInnerHeight() {
if (document.all) return document.body.clientHeight;
else if (document.getElementById) return window.innerHeight;
else if (document.layers) return window.innerHeight;
}

function DOMElementGetHeight(o) {
if (document.all) return o.clientHeight;
else if (document.getElementById) return parseInt(o.offsetHeight);
else if (document.layers) return o.document.height;
}

function DOMElementGetWidth(o) {
if (document.all) return o.clientWidth;
else if (document.getElementById) return parseInt(o.offsetWidth);
else if (document.layers) return o.document.width;
}

function pageOffset() {
var o = DOMGetElement('o');
if (o) {
DOMElementSetLeftPos(o, DOMWindowGetXOffset() + DOMWindowGetInnerWidth() - DOMElementGetWidth(o) - 0);
DOMElementSetTopPos(o, DOMWindowGetYOffset() + DOMWindowGetInnerHeight() - DOMElementGetHeight(o) - 0);

setTimeout('pageOffset()',10);
}
}
//--></script>

sad69
05-26-2004, 08:31 PM
It's definately in the pageOffset() function as this is where it sets the position. If you wanted it on the right, you'd care about how wide the screen should be, but since you want it on the left, you don't care about the width. So I would say to get rid of the red code, but I don't know necessarily if it would work or not. You may just set the left to 0, so use the commented out line instead of the line above it.


function pageOffset() {
var o = DOMGetElement('o');
if (o) {
DOMElementSetLeftPos(o, DOMWindowGetXOffset() + DOMWindowGetInnerWidth() - DOMElementGetWidth(o) - 0);
//DOMElementSetLeftPos(o, 0);
DOMElementSetTopPos(o, DOMWindowGetYOffset() + DOMWindowGetInnerHeight() - DOMElementGetHeight(o) - 0);

setTimeout('pageOffset()',10);
}
}


Try these two, and if it doesn't work, post back and we'll see what else we can monkey with.

Good luck,
Sadiq.

danl linehan
05-26-2004, 08:41 PM
duh, that makes perfect sense... thank you so much!!! i really appreciate it!!!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum