Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 17th, 2005, 12:19 PM
Registered User
 
Join Date: Apr 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Question about "floating div" JavaScript

I have a JavaScript that automatically moves a <div> element to the top-right portion of the clients screen when the screen is resized. This script works great in always presenting a particular element (floating layer <div>) I have on the page against the right margin irrespective of the client's screen resolution. However - the script not only moves the <div> to the right-most margin of the screen - but also moves the <div> vertically to keep it atop the screen when the page is scrolled, etc. I do NOT want the vertical (Y) functionality of the JavaScript. I wish for the <div> to be anchored at an absolute vertical position on the screen and not move when the page is resized, scrolled vertically. Can someone take a look at the following script and let me know what I need to do to eliminate the vertical (Y) repositioning of the div and keep it anchored at an absolute Y position? I thank you in advance.



<div id="picStrip" style="position:absolute; left: 348px; width: 900px; height: 152px; top: 86px;" align="right">
<img src="../images/strip_bldg.jpg"> <img src="../images/strip_board.jpg"> <img src="../images/strip_conf.jpg"> <img src="../images/strip_lobby.jpg"></div>
</div>


<script type="text/javascript">
var ns = (navigator.appName.indexOf("Netscape") != -1);
var d = document;
var px = document.layers ? "" : "px";
function JSFX_FloatDiv(id, sx, sy)
{
    var el=d.getElementById?d.getElementById(id):d.all?d.a ll[id]:d.layers[id];
    window[id + "_obj"] = el;
    if(d.layers)el.style=el;
    el.cx = el.sx = sx;el.cy = el.sy = sy;
    el.sP=function(x,y){this.style.left=x+px;this.styl e.top=y+px;};
    el.flt=function()
    {
    var pX, pY;
    pX = (this.sx >= 0) ? 0 : ns ? innerWidth :
    document.documentElement && document.documentElement.clientWidth ?
    document.documentElement.clientWidth : document.body.clientWidth;
    pY = ns ? pageYOffset : document.documentElement &&
        document.documentElement.scrollTop ?
    document.documentElement.scrollTop : document.body.scrollTop;
    if(this.sy<0)
    pY += ns ? innerHeight : document.documentElement &&
        document.documentElement.clientHeight ?
    document.documentElement.clientHeight : document.body.clientHeight;
    this.cx += (pX + this.sx - this.cx)/8;this.cy += (pY + this.sy - this.cy)/8;
    this.sP(this.cx, this.cy);
    setTimeout(this.id + "_obj.flt()", 1);
    //this.id + "_obj.flt()";
    }
    return el;
}


JSFX_FloatDiv("picStrip", -906, 96).flt();
</script>





Similar Threads
Thread Thread Starter Forum Replies Last Post
XML question on div jastao XSLT 6 June 6th, 2008 05:24 PM
Remove/Hide Div in Javascript Popup markmon Javascript How-To 2 March 24th, 2008 09:10 AM
centered floating div farrellj HTML Code Clinic 2 January 2nd, 2006 09:49 AM
Javascript with <div> aware Javascript How-To 3 August 25th, 2005 05:57 AM
Div Question interrupt Javascript How-To 8 July 19th, 2005 08:46 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.