473,785 Members | 2,831 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3670

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.getEl ementById) {
document.getEle mentById('ta1') .scrollTop = this.scrollTop;
document.getEle mentById('ta2') .scrollTop = this.scrollTop;
}"
style="position : absolute; top: 113; left:654; height: 96px; width:
16px; overflow: auto;">
<br><br><br><br ><br><br><br><b r><br><br><br>< br><br><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.c om> wrote in message
news:11******** **************@ g14g2000cwa.goo glegroups.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'onscrol l="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.g etElementById(' ta1'),
ref2=document.g etElementById(' ta2');
var vPos1=ref1.scro llTop,vPos2=ref 2.scrollTop;

function scrollTa()
{
if(ref1.scrollT op!=vPos1)
vPos1=ref2.scro llTop=ref1.scro llTop;
else
if(ref2.scrollT op!=vPos2)
vPos2=ref1.scro llTop=ref2.scro llTop;

setTimeout('scr ollTa()',250)
}

window.onload=s crollTa;

</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
14583
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 concoction which does something useful in IE and also in Mozilla 1.4. However, the problem is that it only works in Mozilla if I say overflow:auto in the top frame, it ceases working if I say overflow:hidden. But saying overflow:hidden is...
5
16028
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 height of 100%), it displays properly.. But firefox hardly produce the scrollbars on that division, and instead makes the whole page to scroll. I know there is some incompatibility between the two browsers as far as following the CSS standards,...
6
4638
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 anyone help. Thanks Stuart
3
4690
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 'window.pageXOffset' and 'window.pageYOffset' are not correct. Is there any other way to get the correct scrolling offsets?
4
7807
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 find the text and select it using the function below, BUT I can't figure out how to have the textarea automatically scroll to the selection in Firefox. Any ideas or suggestions? function search(needle,haystack,start) { var element =...
3
2719
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 second DataGrid's DataSource. All that works very well. And, when there are no records to display, it is simply left blank. My issue is that when i scroll the first one, sometimes the second grid shows a bunch of null values (a "new" record). ...
5
4268
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 text.. ' function scrollMsg(){
3
2451
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 need to create is if one program enables this "sync" feature, other instances of this application will scroll in sync while the base one's scroll bar is moved. Is remoting the best way to do this? Or is there another way? I'm just concerned...
29
3325
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 use it in sync mode. Any ideas what can I do? Thanks, Zalek.
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10324
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9949
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8971
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7499
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4050
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.