Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    sbq
    sbq is offline
    New to the CF scene
    Join Date
    Jul 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    test HTML object for event handler

    We have the following snippet of code:

    Code:
    function buildLink(id, value) {
        var url = parent.modelGet(id) 
        var el = document.getElementById(id)
        ... code that adds innerText to el
        if (el.onchange)
            el.onchange()
    
    }
    I'm getting an error in IE 7 Beta 3 for the line in red, claiming the "object does not support this property or method". The claim is true, but the point of the if-test in the line above is to insure we only call onchange() for objects that have an onchange() handler.

    This code has worked for us for IE6, Firefox, etc. Is this a bug in IE 7 Beta 3? Or are we misusing that if-test?

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,048
    Thanks
    0
    Thanked 251 Times in 247 Posts
    Try alerting its type if it indeed returns a function pointer.
    Code:
    alert(typeof el.onchange)


  •  

    Posting Permissions

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