SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Sep 2006
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    "for in" loop producing FF error

    Can anyone shed some light on why this is producing an error in FF.

    Code:
    <input type="button" name="my_btn" value="Click Here" onclick="for(var j in this) { alert(j + ' : ' + this[j]); }" />
    Here's the error
    Error: uncaught exception: [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIDOMNSHTMLInputElement.selectionStart]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: http://localhost/error.html :: onclick :: line 1" data: no]
    PHP MySQL Shopping Cart
    www.eprocart.com

  2. #2
    SitePoint Wizard gRoberts's Avatar
    Join Date
    Oct 2004
    Location
    Birtley, UK
    Posts
    2,439
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    shouldn't it be, foreach(j in this)


  3. #3
    SitePoint Member
    Join Date
    Sep 2006
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm not sure but is foreach a javascript function?
    PHP MySQL Shopping Cart
    www.eprocart.com

  4. #4
    SitePoint Wizard gRoberts's Avatar
    Join Date
    Oct 2004
    Location
    Birtley, UK
    Posts
    2,439
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry I completely misunderstood the question. It seems that your trying to read a property that cannot be read basically. Using try{} catch(e){} you can stop errors from appearing.

    Also, why are you doing this?



Bookmarks

Posting Permissions

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