Help needed with event testing script

M

Mark Szlazak

Apparently there is a textarea onscroll event bubbling bug in Firefox
and Mozilla:

https://bugzilla.mozilla.org/show_bug.cgi?id=229089

I'm trying to check for this bug with the following script and it
*seems* to work. In IE it reports "bubbling" and in Firefox "not
bubbling" but I really have no direct way to confirm the Firefox
results until the bubbling bug is fixed.

Basically the test script assigns an onscroll event handler to a
textarea and then scrolls the textarea down then back up, checking to
see if a the event handler works (assigns the "bubbling" variable a
"true").

I had to code things with a few settimeouts otherwise Firefox, unlike
IE, wouldn't display the down then back up scrolling of the textarea.
Which may have been a problem.

Lacking a "debugged" Firefox browser, is there some further (indirect?)
tests and/or rational that would support or discredit this script as a
valid onscroll event check?

<html>
<head>
<script>
var bubbling, ta;

function checkBubbling () {
var str = '';
bubbling = false;
ta.onscroll = function () { bubbling = true; }

for (var i=0; i <= ta.rows; i++) str += '\n';
ta.value = str;
ta.scrollTop = ta.scrollHeight;

setTimeout("scrollBack ()", 1);
}

function scrollBack () {
ta.scrollTop = 0;
setTimeout("resetAndReport ()", 1);
}

function resetAndReport () {
ta.value = "";
if (bubbling)
{
alert('bubbling');
}
else
{
alert('not bubbling');
}
}

onload = function ()
{
ta = document.getElementById('ta');
ta.value = "";
checkBubbling();
}
</script>
</head>
<body>
<textarea id="ta" rows=5 cols=40></textarea>
</body>
</html>
 
M

Martin Honnen

Mark said:
Apparently there is a textarea onscroll event bubbling bug in Firefox
and Mozilla:

https://bugzilla.mozilla.org/show_bug.cgi?id=229089

I'm trying to check for this bug with the following script and it
*seems* to work. In IE it reports "bubbling" and in Firefox "not
bubbling" but I really have no direct way to confirm the Firefox
results until the bubbling bug is fixed.

Basically the test script assigns an onscroll event handler to a
textarea and then scrolls the textarea down then back up, checking to
see if a the event handler works (assigns the "bubbling" variable a
"true").

If script scrolls then I am not sure Mozilla fires the scroll event, it
should fire it when the user scrolls. At least for a window a quick test
shows that window.scrollTo() doesn't fire the scroll event and even if
onscroll worked for textareas then I don't think the scroll event would
be fired if script manipulates the scroll settings.
 
M

Mark Szlazak

Martin said:
If script scrolls then I am not sure Mozilla fires the scroll event, it
should fire it when the user scrolls. At least for a window a quick test
shows that window.scrollTo() doesn't fire the scroll event and even if
onscroll worked for textareas then I don't think the scroll event would
be fired if script manipulates the scroll settings.

OK, with regard to textarea scripts firing onscroll events, why is
there this difference between IE and Firefox?

Also, do you have any suggestions for checking if the textarea onscroll
event in Firefox is working?

Thanks. Mark.
 
M

Mark Szlazak

Martin said:
If script scrolls then I am not sure Mozilla fires the scroll event, it
should fire it when the user scrolls. At least for a window a quick test
shows that window.scrollTo() doesn't fire the scroll event and even if
onscroll worked for textareas then I don't think the scroll event would
be fired if script manipulates the scroll settings.

If the user has to scroll the textarea to get a fire from onscroll in a
bugfree firefox then what about user inputs that show the scrollbars
once enough lines are entered into the textarea. I'm thinking about a
script something like this:

<html>
<head>
<script>
var bubbling, ta;

onload = function ()
{
bubbling = false;
ta = document.getElementById('ta');
ta.value = "";
ta.onscroll = function () { bubbling = true; }
if (ta.addEventListener) {
ta.addEventListener("input",
function () { if (ta.scrollHeight > ta.clientHeight)
{
if (bubbling)
{
window.status = 'bubbling';
}
else
{
window.status = 'not bubbling';
}
}
},
false);
}
}
</script>
</head>
<body>
<textarea id="ta" rows=5 cols=40></textarea>
</body>
</html>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top