/    Sign up×
Community /Pin to ProfileBookmark

synchronizing 2 seperate <DIV>

I currently have 2 seperate <DIV>’s each with a horizontal scroll. I want to link the scroll bars so when I scroll DIV 2 I want DIV 1 to scroll also. Any ideas?

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@7studFeb 03.2005 — Any ideas?[/QUOTE]
Wire $500 to my Paypal account and I'll get started?
Copy linkTweet thisAlerts:
@ElegiditoFeb 04.2005 — Came up with this...although onScroll isn't valid, it works in IE
<i>
</i> &lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd"&gt;
&lt;html lang="en"&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"&gt;
&lt;meta name="Content-Style-Type" content="text/css"&gt;
&lt;title&gt;Scrolling Div Thing&lt;/title&gt;
&lt;style type='text/css'&gt;
#div1,#div2 {
height:35px;
width:200px;
overflow:scroll;
white-space:nowrap;
}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id='div1'&gt;
Lots, and lots, and lots
and lots, and lots, and lots, and lots, and lots, and lots,
and lots, and lots, and lots,and lots, and lots, and lots,
of data&lt;/div&gt;
&lt;div id='div2' onScroll='document.getElementById("div1").scrollLeft=this.scrollLeft;'&gt;And some more, more, more, more, more, more, more,
more, more, more, more, more, more, more, more, more, more, more,
more, more, more, more, data
&lt;/div&gt;
&lt;/body&gt;


hope that helps
Copy linkTweet thisAlerts:
@ckopackoauthorFeb 04.2005 — That worked great in IE except for some reason I had to use document.all.div1.scrollLeft=this.scrollLeft. Is there any event that netscape or safari will recognize when a user scroll?

Thanks for the help.
Copy linkTweet thisAlerts:
@PittimannFeb 04.2005 — Hi![i]Originally posted by ckopacko [/i]

[B]That worked great in IE except for some reason I had to use [COLOR=red]document.all.div1[/COLOR].scrollLeft=this.scrollLeft. Is there any event that netscape or safari will recognize when a user scroll?[/B][/QUOTE]
You should get rid of the red stuff because this only works in IE (and in some browsers 'pretending' to be IE).

Elegidito's code (exactly like posted here) also works in FF, Mozilla and NS7).

Cheers - Pit
×

Success!

Help @ckopacko spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...