By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,978 Members | 1,373 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,978 IT Pros & Developers. It's quick & easy.

Help needed with event testing script

P: n/a
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>

Jul 23 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a


Mark Szlazak wrote:
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.


--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #2

P: n/a
Martin Honnen wrote:
Mark Szlazak wrote:
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.


--

Martin Honnen
http://JavaScript.FAQTs.com/


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.

Jul 23 '05 #3

P: n/a


Mark Szlazak wrote:

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


That bug you have found has a test case:
<https://bugzilla.mozilla.org/show_bug.cgi?id=229089>
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #4

P: n/a

Martin Honnen wrote:
Mark Szlazak wrote:

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


That bug you have found has a test case:
<https://bugzilla.mozilla.org/show_bug.cgi?id=229089>
--

Martin Honnen
http://JavaScript.FAQTs.com/


Yes! It demonstrates the bug but provides no work-around.
I was hoping for bug detection without browser version detection but no
luck ... I guess.

Mark.

Jul 23 '05 #5

P: n/a

Martin Honnen wrote:
Mark Szlazak wrote:
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.


--

Martin Honnen
http://JavaScript.FAQTs.com/


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>

Jul 23 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.