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

PgUp scrolling in FF

P: 3
Hi,

I found following problem in FF 3.0.9 (it looks it is FF problem only). See few lines of code below:

Expand|Select|Wrap|Line Numbers
  1. <html>
  2.    <head>
  3.        <title>TEST</title>
  4.        <script type="text/javascript">
  5.            function act() {
  6.                document.getElementById('p_id').innerHTML = '';
  7.            }
  8.        </script>
  9.    </head>
  10.    <body style="padding: 400px;">
  11.        <p id="p_id"><input type="text" id="text" onkeypress="javascript: act();" /></p>
  12.        <a href="javascript://" onclick="javascript: act();">remove by click</a>
  13.    </body>
  14. </html>

There is function act() that clear content of P element. To reproduce problem start with click on link "remove by click". After click you can try use PgUp and PgDown keys. You can see that
scrolling of page works without problem. Then refresh page and insert cursor in the text field and try type anything.
After first press, handler is executed and content of P is deleted (same function act()). !!Only difference is that scolling
through PgUp and PgDown keys does not work after this action!!. This problem is in FF only (tested IE6,IE7, Opera).

This is only model. I use similar function to change value in table cell and in keydown handler catch ENTER.
Then I save data through AJAX to database ..after response is cell replaced by new value (but scrolling doesnt work).

Is it firefox internal problem? Any idea how to make scrolling works in FF after keypress?

Thanks

Rosta
Apr 29 '09 #1
Share this Question
Share on Google+
4 Replies


Expert 100+
P: 392
Ok,

I think I see what is going on here. Once you select the text input field the field then absorbs all keyboard events. So if you change the trigger event from something like onkey to onmouseover the act() function is called before the text field is selected. And your keyboard events are not swallowed by the text field. Once a text field is selected though the keyboard events are swallowed by the text field, and you have to select something else on the page before events will work on the page again.


Expand|Select|Wrap|Line Numbers
  1. <html>
  2.    <head>
  3.        <title>TEST</title>
  4.        <script type="text/javascript">
  5.            function act() {
  6.                document.getElementById('p_id').style.display='none';
  7.                document.getElementById('p_id').focus();
  8.            }
  9.        </script>
  10.    </head>
  11.    <body style="padding: 400px;">
  12.           <form >
  13.            <p id="p_id" ><input type="test" id="inputOne" onmouseover="javascript: act(); return false;" /></p>
  14.         <input type="test" id="inputTwo" />
  15.         <a id="link" href="javascript://" onclick="javascript: act();">remove by click</a>
  16.        </form>
  17.    </body>
  18. </html>
  19.  
Apr 29 '09 #2

P: 3
Im able trigger event with onmouseover..this is ok, but then have to add
some onkey handler that check what I typed in field (in real situation there can be fields for example
with validators) and in case of ENTER I delete field (with innerHTML = '' (or html('')..Im using jQuery ))
and scrolling stop work. Even if I set focus back to page then scrolling is out. See
my original code with focus to newfield in the end of act function, I tried other
things like select text or click on checkbox to revive page but nothing works.

Expand|Select|Wrap|Line Numbers
  1. <html>
  2.     <head>
  3.         <title>TEST</title>
  4.         <script type="text/javascript">
  5.             function act() {
  6.                 document.getElementById('p_id').innerHTML = '';
  7.                 //document.getElementById('newfield2').focus();
  8.                 document.getElementById('newfield1').click();
  9.                 document.getElementById('newfield1').focus();
  10.             }
  11.         </script>
  12.     </head>
  13.     <body style="padding: 400px;">
  14.         <input type="checkbox" id="newfield1" />
  15.         <input type="text" id="newfield2" />
  16.         <p id="p_id"><input type="text" id="text" onkeypress="javascript: act();" /></p>
  17.         <a href="javascript://" onclick="javascript: act();">remove by click</a>
  18.     </body>
  19. </html>
Apr 29 '09 #3

Expert 100+
P: 392
@rosta
And as I already explained that is going to happen each time the user selects an input field. None of the key events are going to trigger until the user has selected something else.

Why does it matter if the user can use the page up or down buttons any way. If they have selected a textfield that they are entering data, why would they want to move off of the page. They would not be able to see what they are entering.
Apr 29 '09 #4

P: 3
For now, I want only that user is able to scroll with PgUp PgDown after field edit...Please look at my last post carefully where in last steps of act() function I write this:
Expand|Select|Wrap|Line Numbers
  1. document.getElementById('newfield1').click();
  2. document.getElementById('newfield1').focus();
this select other element on page according your "None of the key events are going to trigger until the user has selected something else" ;) ...but scrolling still doesnt work...try to test (in FF and then in other browsers) ;)

Looking forward your answer

Rosta
Apr 29 '09 #5

Post your reply

Sign in to post your reply or Sign up for a free account.