473,246 Members | 1,703 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,246 software developers and data experts.

Scrolling textareas in sync with Firefox

How do I scroll two textareas in sync with FireFox/Mozilla? The IE
solution has been posted before by Martin Honnen.

Jul 23 '05 #1
5 3590

Mark wrote:
How do I scroll two textareas in sync with FireFox/Mozilla? The IE
solution has been posted before by Martin Honnen.


No one has answered and a bit more searching seems to say that a bug
prevents the textarea onscroll event from firing in past or current
versions of Mozilla or Firefox.

The following code/hack seems to work in Firefox 1.01 on Win2k. It
aligns a appropriately sized DIV with scrollbars so it completely
covers the scrollbars of the lower textarea. This DIV's scrollbar is
used to synchronously scroll both upper and lower textareas.

Has anyone got some other/better work arounds?

<html>
<head>
<script>
</script>
</head>
<body>
<textarea id="ta1" rows=5 cols=80>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20</textarea>
<textarea id="ta2" rows=5 cols=80>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20</textarea>
<div onscroll="if (document.getElementById) {
document.getElementById('ta1').scrollTop = this.scrollTop;
document.getElementById('ta2').scrollTop = this.scrollTop;
}"
style="position: absolute; top: 113; left:654; height: 96px; width:
16px; overflow: auto;">
<br><br><br><br><br><br><br><br><br><br><br><br><b r><br><br><br><br><br>
</div>
</body>
</html>

Jul 23 '05 #2
rh
Mark wrote:
Mark wrote:
How do I scroll two textareas in sync with FireFox/Mozilla? The IE
solution has been posted before by Martin Honnen.


No one has answered and a bit more searching seems to say that a bug
prevents the textarea onscroll event from firing in past or current
versions of Mozilla or Firefox.

The following code/hack seems to work in Firefox 1.01 on Win2k. It
aligns a appropriately sized DIV with scrollbars so it completely
covers the scrollbars of the lower textarea. This DIV's scrollbar is
used to synchronously scroll both upper and lower textareas.

Has anyone got some other/better work arounds?


It's not at all clear why you would want to do this, but presumably
this would only make sense if the content of the textareas is
equivalenced and synchronized as well.

An alternative, for FF and Netscape, would be to sync on
mouseup/mousemove (and keyup) events in the textarea elements, as it
seems mouse events are delivered when mouse activation is initiated
within the scroll bar areas.

This won't work for Mozilla, as it doesn't appear to deliver updated
scrollTop/Left values for the textareas.

../rh

Jul 23 '05 #3


Mark <ms******@aol.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
How do I scroll two textareas in sync with FireFox/Mozilla? The IE
solution has been posted before by Martin Honnen.


If this type of event isn't available, you can use simulate it using
periodic monitoring. The following example demonstrates the principle and
works in I.E. and Mozilla but not Opera. Under I.E. it works more smoothly
if the function is called also by the onscroll event:

<textarea id='ta1'onscroll="scrollTa()) ...... >

and you can experiment with shorter timeout the delays.

You don't say whether you want master/slave or dual master scrolling,
however if you want master/slave, remove the redundant code.

<script type='text/javascript'>

var ref1=document.getElementById('ta1'),
ref2=document.getElementById('ta2');
var vPos1=ref1.scrollTop,vPos2=ref2.scrollTop;

function scrollTa()
{
if(ref1.scrollTop!=vPos1)
vPos1=ref2.scrollTop=ref1.scrollTop;
else
if(ref2.scrollTop!=vPos2)
vPos2=ref1.scrollTop=ref2.scrollTop;

setTimeout('scrollTa()',250)
}

window.onload=scrollTa;

</script>
--
S.C. http://makeashorterlink.com/?H3E82245A

Jul 23 '05 #4

rh wrote:
It's not at all clear why you would want to do this, but presumably
this would only make sense if the content of the textareas is
equivalenced and synchronized as well.
Yes that's exactly it. Data values are transform into others and it is
very convenient to sync data pairs.
An alternative, for FF and Netscape, would be to sync on
mouseup/mousemove (and keyup) events in the textarea elements, as it
seems mouse events are delivered when mouse activation is initiated
within the scroll bar areas.

This won't work for Mozilla, as it doesn't appear to deliver updated
scrollTop/Left values for the textareas.

../rh


I haven't tried my posted solution in Mozilla but any solution should
work their as well.

Thanks for your suggestions.

Mark.

Jul 23 '05 #5
Thanks, I'll check this one out as well.

Cheers. Mark.

Jul 23 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Kai Grossjohann | last post by:
I'm trying to synchronize the scrolling of two <div> elements. The top element is for showing column headers, the bottom div shows the table rows. I consed up the following HTML/JavaScript...
5
by: Steve Belanger | last post by:
Has anybody heard or figured out a way to make a DIV with overflow: scroll to look the same in IE and Firefox in IE i have one table splitted in two, the bottom part is the scrolling (Set to a...
6
by: stuart | last post by:
I have two textareas on a HTML page. If a user scrolls in one textarea I want the other textarea to scroll as well. In otherwords I want both textareas to scroll up and down in unison. Can...
3
by: Vikram Bhatia | last post by:
1. Is there an event to capture scrolling using mouse wheel in Netscape 6.x? 2. When arrow keys are used to scroll a page in Netscape 6.x, the scrolling offsets obtained using...
4
by: Keith Bentrup | last post by:
Hi all, I wrote a simple search function to find text in a textarea where not all the text is visible (ie. the text box displays 10 lines but there may be more than 1000 lines to search). I can...
3
by: Brian Tkatch | last post by:
I have a form with two DataGrids, which are kept in sync manually via Stored PROCEDURE calls. That is, when a record is selected on the first grid, a stored PROCEDURE is CALLed to Fill() the next...
5
by: PythonistL | last post by:
I am a newbie with Javascript. I have this simple script for scrolling text <HTML> <HEAD> <TITLE>Scrolling Message Script</TITLE> <SCRIPT language="JavaScript"><!-- var msg = 'My scrolling...
3
by: Roe | last post by:
What is the best way using C# .NET 1.1 to have two (or more) applications perform a "synchronized" scrolling? These applications will all be C# .NET and will be on the same machine. The effect I...
29
by: zalek | last post by:
I am writing application with Ajax in sync mode - xmlHttp.open("GET", url, false). I noticed that in FireFox handler doesn't starts. It starts when I use xmlHttp.open("GET", url,true). I need to...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.