Hi all,
I am new to JavaScript. i am making a page which shoud have a div floating. i changed the position to fixed which solved it but now i want to change the position to the absolute on condition that when the scrolling div comes to a certain area i can change it is that consider the code
the div container is the parent div with height 500px and div formButtons is the scrolling divCode:<div id="container" > <DIV id="formButtons"><asp:Button id="Button1" onclick="Button1_Click" runat="server" BackColor="Aqua" Width="201px" Text="Save Form"></asp:Button> </DIV></div>
i want scroling div to move in the parent div is that if i scroll to the bottom the scrolling div should stick on the bottom of the container div
the javascript i used for this is as follows it works but the problem is i am using constant values it will work if the window is of specific size is there any way to get the end position of the parent div
what should i do please Help?Code:window.onscroll = function() { if (document.documentElement.scrollTop < "530") //the value i have putten in quatation is the constant where i need a certain function to dynamicaly get the values the value entered here is one where i want div to stick but it changes when maximized { document.getElementById("formButtons").style.position= 'fixed'; document.getElementById("formButtons").style.bottom= '0px'; document.getElementById("formButtons").style.right= '0px'; } else { document.getElementById("formButtons").style.position='absolute'; document.getElementById("formButtons").style.right='0px'; document.getElementById("formButtons").style.bottom="'-690px'"; the value here should also be assigned dynamically on parent container bottom right } }


Reply With Quote

Bookmarks