Wrox Programmer Forums
|
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To 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 July 29th, 2004, 09:37 AM
sam sam is offline
Authorized User
 
Join Date: Jun 2003
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by anshul
 4Netscape family corresponding property is 'pageYOffset' lieu 'document.body.scrollTop' that works4 MSIE. We need if..else or seperate function body4this distinction.

setTimeout("scrollMenu(str)",100);
is one correction i do now.

there may b more typing mistakes.
I was unable to implement your code but I think I totally off base please clarify:
Code:
<html>
<head>
</head>
<body>
<div id="menu" style="width:100;height:100;background-color:black"></div>

<SCRIPT LANGUAGE=javascript>
<!--
var initpos, scroll, newpos, str;

function initScroll(menu) {
 str=eval('menu');
 initpos=parseInt( 
  document.getElementById(str).style.top);
 }

function scrollMenu(menu) {
 scroll=parseInt(document.body.scrollTop);
 newpos=pos+scroll;
 str=eval('menu');
 document.getElementById(menu).style.top=newpos;
 str=eval('menu');
 setTimeout("scrollMenu(str)",100);
 }

//now u just need2call functions externally

initScroll('scrollMenu');
scrollMenu('scrollMenu');
//-->
</SCRIPT>




<TABLE WIDTH="75%" BORDER=1 CELLSPACING=1 CELLPADDING=1 height=900>
    <TR>
        <TD>1</TD>
        <TD>2</TD>
        <TD>3</TD>
    </TR>
    <TR>
        <TD>4</TD>
        <TD>5</TD>
        <TD>6</TD>
    </TR>
    <TR>
        <TD>7</TD>
        <TD>8</TD>
        <TD>9</TD>
    </TR>
</TABLE>
</body>
</html>
~~~~~~~~~~~~~~~~~~~~~~~
http://byldesigns.com
~~~~~~~~~~~~~~~~~~~~~~~
 
Old July 30th, 2004, 03:06 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 357
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anshul
Default

hi sam,

u need hust define these functions in <HEAD> or seperate .js file.
create a <DIV> with id="scrollMenu"

call the functions then.
please try. u'll get it2work.
 
Old August 4th, 2004, 09:51 AM
sam sam is offline
Authorized User
 
Join Date: Jun 2003
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the lead, I needed to make the div "POSITION: absolute " plus I fixed some typos.
Code:
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
<SCRIPT LANGUAGE=javascript>
<!--
var scroll, newpos, pos;
newpos=0;
function initScroll(menu) {
    pos=parseInt(document.getElementById(menu).style.top);
 }

function scrollMenu(menu) {
 scroll=parseInt(document.body.scrollTop);
 newpos=pos+scroll;
 document.getElementById(menu).style.top=newpos;
 setTimeout("scrollMenu('scrollMenu')",100);
 }

//-->
</SCRIPT>

</HEAD>
<BODY>

<div id="scrollMenu" style="Z-INDEX: 100; LEFT: 880px; WIDTH: 100px; POSITION: absolute; TOP: 198px; HEIGHT: 100px; BACKGROUND-COLOR: black"><A HREF="http://www.ebcpro.com"><center><BR>click here for help</center></A></div>

<TABLE WIDTH="75%" BORDER=1 CELLSPACING=1 CELLPADDING=1 height=1900>
    <TR>
        <TD>1c</TD>
        <TD>2</TD>
        <TD>3</TD>
    </TR>
    <TR>
        <TD>4</TD>
        <TD>5</TD>
        <TD>6</TD>
    </TR>
    <TR>
        <TD>7</TD>
        <TD>8</TD>
        <TD>9</TD>
    </TR>
</TABLE>
<SCRIPT LANGUAGE=javascript>
<!--

initScroll('scrollMenu');
 setTimeout("scrollMenu('scrollMenu')",100);
//-->
</SCRIPT>


</BODY>
</HTML>
~~~~~~~~~~~~~~~~~~~~~~~
http://ebcpro.com.com
      where EveryBusinessCounts
~~~~~~~~~~~~~~~~~~~~~~~





Similar Threads
Thread Thread Starter Forum Replies Last Post
Javascript with <div> aware Javascript How-To 3 August 25th, 2005 05:57 AM
<marquee> scrolling swastikagaur HTML Code Clinic 2 March 30th, 2005 03:56 AM
<style> tags in a <body> vs. <div> bcat BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 1 March 27th, 2005 08:50 AM
sizeable <div> johnjohn Javascript How-To 1 December 8th, 2004 08:28 PM
<A><DIV><TABLE></DIV></A> anshul HTML Code Clinic 2 July 17th, 2004 02:17 PM





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