dcsimg
www.webdeveloper.com
Results 1 to 3 of 3

Thread: onblur problems in ie

  1. #1
    Join Date
    Jul 2006
    Posts
    14

    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. #2
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,279
    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. #3
    Join Date
    Jul 2006
    Posts
    14
    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>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center