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 June 4th, 2003, 07:59 AM
Authorized User
 
Join Date: Jun 2003
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to tgopal
Default How to scroll Layer using javascript

Is there a way to scroll an layer using javascript.
For example

<DIV STYLE="overflow:auto; height: 365; width: 780; class="ColorBG">
<TABLE id ="JobsTable" border="1" cellpadding="0" cellspacing="0" width="750" class="TDBGWhite">
//Table Rows
</TABLE>
</DIV>

If the Table heigth exceeds the height 365 then scroll bar appears.How can i scroll the layer using javascript.
Thanks
T.Gopalakrishnan
 
Old June 12th, 2003, 12:42 PM
Authorized User
 
Join Date: Jun 2003
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Dan Jallits Send a message via MSN to Dan Jallits Send a message via Yahoo to Dan Jallits
Default

I received the code from http://www.uwyn.com/projects/relativ...tion/x377.html
Code:
<HTML>
<HEAD>
<TITLE>RelativeLayers : Available area example</TITLE>
<SCRIPT LANGUAGE="JavaScript" SRC="rl_error_stripped.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" SRC="rl_browser_stripped.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript1.2" SRC="rl_utility_stripped.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript1.2" SRC="rl_window_stripped.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript1.2" SRC="rl_layer_stripped.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript1.2">
<!--
layer1 = new RelativeLayer(
"layer1Div", "", "",
"100%","AUTO",LEFT,"0",TOP,"0","-50%","-50%",
"100%","100%",LEFT,"50%",TOP,"50%","0","0",
"#dddddd", "");
layer1.setVisible(true);

layer2 = new RelativeLayer(
"layer2Div", "", "",
"30%","50%",LEFT,"50%",TOP,"50%","0","0",
"200%","AUTO",LEFT,"50%",TOP,"0","0","-50%",
"#dddddd", "");
layer2.setVisible(true);

var htmltext = "top top top top top top top top top top<BR><BR>";
for(var i = 0; i < 7; i++)
{
    for(var j = 0; j < 5; j++)
    {
        htmltext += "This is just a bit of text to fill up space.";
    }
    htmltext += "<BR><BR>";
}
htmltext += "bottom bottom bottom bottom bottom<BR>";
layer2.setHtml(htmltext);
//-->
</SCRIPT>
</HEAD>

<BODY BGCOLOR="#ffffff">

<DIV ID="layer1Div">
<CENTER>
<A HREF="javascript://" ONMOUSEDOWN="return layer2.startScroll(0, 10);"
              ONMOUSEUP="return layer2.stopScroll();">scroll up</A><BR>
<A HREF="javascript://" ONMOUSEDOWN="return layer2.startScroll(10, 0);"
              ONMOUSEUP="return layer2.stopScroll();">scroll left</A>
<A HREF="javascript://" ONMOUSEDOWN="return layer2.startScroll(-10, 0);"
              ONMOUSEUP="return layer2.stopScroll();">scroll right</A><BR>
<A HREF="javascript://" ONMOUSEDOWN="return layer2.startScroll(0, -10);"
              ONMOUSEUP="return layer2.stopScroll();">scroll down</A><BR>
</CENTER>
</DIV>

<DIV ID="layer2Div">
</DIV>

</BODY>

</HTML>
Best Regards,
Dan Jallits
 
Old June 16th, 2006, 10:19 AM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

I realize this thread is old, but I happened upon it while searching for an answer to this question.

The answer to the original question is to use the scrollTop and scrollLeft properties, in addition to scrollWidth and scrollHeight.

In my case, I was looking for a way to auto scroll to the bottom of a <div> with overflow: auto; set. I did that like so:

Code:
var $obj = document.getElementById('some-element');

// Scroll to the bottom!
$obj.scrollTop = $obj.scrollHeight;
Regards,
Rich

--
Author,
Beginning CSS: Cascading Style Sheets For Web Design
CSS Instant Results

http://www.catb.org/~esr/faqs/smart-questions.html





Similar Threads
Thread Thread Starter Forum Replies Last Post
Handle error from database layer to applican layer khatu_jec ASP.NET 2.0 Basics 1 November 9th, 2008 03:51 PM
Menu layer wdwright BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 1 January 18th, 2007 08:11 PM
Layer Problem socoolbrewster CSS Cascading Style Sheets 4 August 2nd, 2006 12:33 PM
onClick outside a layer markp Javascript How-To 1 July 8th, 2004 08:59 AM





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