|
|||||||
| JavaScript JavaScript (not Java) Discussion and technical support, including AJAX and frameworks (JQuery, MooTools, Prototype...) |
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
onblur problems in ie
im creating an input with javascript. im assigning it an onblur attribute. it works fine in firefox, but not in ie (on pc). any ideas? thx.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <script> window.onload = function() { var newInput = document.createElement("input"); newInput.setAttribute("onblur","alert(this.value)"); document.getElementsByTagName("form")[0].appendChild(newInput); } </script> </head> <body> <form> </form> </body> </html> |
|
#2
|
||||
|
||||
|
1) You need to run that through The Validator.
2) Try setting the handler thusly: newInput.onblur = function () {alert (this.value)}.
__________________
“The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.” —Tim Berners-Lee, W3C Director and inventor of the World Wide Web |
|
#3
|
|||
|
|||
|
weird, i responded to this yesterday but it didnt post. anyway, thx! okay here's another one. assigning an attribute of onkeyup with "event" passed in the function breaks the code. thx for any help!
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <script> window.onload = function() { var newInput = document.createElement("input"); newInput.onkeyup = function () {KeyPress(this,event);}; document.getElementsByTagName("form")[0].appendChild(newInput); newInput.focus(); } function KeyPress(inputField,event) { if(event && (event.keyCode == 13 || event.keyCode == 9)){ alert(event.keyCode); return false; } } </script> </head> <body> <form> </form> </body> </html> |
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|