Results 1 to 2 of 2

Thread: thumbnailviewer

  1. #1
    Join Date
    Mar 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default thumbnailviewer

    Hi, I'm a new guest of this site and this is my firtst experience with the FORUM!!!
    I would like to know how I have to change the code
    -----------------------------------------------------------
    centerDiv:function(divobj){ //Centers a div element on the page
    var ie=document.all && !window.opera
    var dom=document.getElementById
    var scroll_top=(ie)? this.standardbody.scrollTop : window.pageYOffset
    var scroll_left=(ie)? this.standardbody.scrollLeft : window.pageXOffset
    var docwidth=(ie)? this.standardbody.clientWidth : window.innerWidth-this.scrollbarwidth
    var docheight=(ie)? this.standardbody.clientHeight: window.innerHeight
    var docheightcomplete=(this.standardbody.offsetHeight>this.standardbody.scrollHeight)? this.standardbody.offsetHeight : this.standardbody.scrollHeight //Full scroll height of document
    var objwidth=divobj.offsetWidth //width of div element
    var objheight=divobj.offsetHeight //height of div element
    var topposition=(docheight>objheight)? scroll_top+docheight/2-objheight/2+"px" : scroll_top+10+"px" //Vertical position of div element: Either centered, or if element height larger than viewpoint height, 10px from top of viewpoint
    divobj.style.left=docwidth/2-objwidth/2+"px" //Center div element horizontally
    divobj.style.top=Math.floor(parseInt(topposition))+"px"
    divobj.style.visibility="visible"
    },
    ----------------------------------------
    for positioning the image on the right instead of the center of the page (and also what I have to do eventually to set the image in a certain pixel of distance from the right margin of the page). (for instance 100px from right margin).

    Thanks al lot to who will be so kind to answer me!!


  2. #2
    Join Date
    Jan 2008
    Posts
    4,167
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Try this:
    Code:
    centerDiv:function(divobj){ //Centers a div element on the page
    var ie=document.all && !window.opera
    var dom=document.getElementById
    var scroll_top=(ie)? this.standardbody.scrollTop : window.pageYOffset
    var scroll_left=(ie)? this.standardbody.scrollLeft : window.pageXOffset
    var docwidth=(ie)? this.standardbody.clientWidth : window.innerWidth-this.scrollbarwidth
    var docheight=(ie)? this.standardbody.clientHeight: window.innerHeight
    var docheightcomplete=(this.standardbody.offsetHeight>this.standardbody.scrollHeight)? this.standardbody.offsetHeight : this.standardbody.scrollHeight //Full scroll height of document
    var objwidth=divobj.offsetWidth //width of div element
    var objheight=divobj.offsetHeight //height of div element
    var topposition=(docheight>objheight)? scroll_top+docheight/2-objheight/2+"px" : scroll_top+10+"px" //Vertical position of div element: Either centered, or if element height larger than viewpoint height, 10px from top of viewpoint
    divobj.style.right="5px" //Center div element horizontally
    divobj.style.top=Math.floor(parseInt(topposition))+"px"
    divobj.style.visibility="visible"
    Jeremy | jfein.net

Bookmarks

Posting Permissions

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