Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Mar 2004
    Posts
    52
    Thanks
    0
    Thanked 0 Times in 0 Posts

    scrolling image problems

    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>

  • #2
    Senior Coder
    Join Date
    Feb 2004
    Posts
    1,206
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    Code:
    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.

  • #3
    New Coder
    Join Date
    Mar 2004
    Posts
    52
    Thanks
    0
    Thanked 0 Times in 0 Posts
    duh, that makes perfect sense... thank you so much!!! i really appreciate it!!!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •