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

Thread: this.id in Internet Explorer what am I doing wrong?

  1. #1
    Join Date
    Oct 2008
    Posts
    2

    this.id in Internet Explorer what am I doing wrong?

    Hello,

    Apologies if this is a bit of a noob question but I have the following function to find the id of an element on mouse click and return the number which is located at character position 4:

    function fnItemNo(e) {
    itnum = parseInt(e.charAt(4),10);
    return itnum;
    }

    The function is called by the following trigger:

    <span onclick="item=fnItemNo(this.id); valueorder=remove(item);">

    The whole thing works beautifully in Firefox but produces a javascript error in IE6 or IE7. MS script debugger doesn't seem to able to pinpoint the error but from it's jargon it seems to be a problem with this.id

    Can anyone point me in the right direction with this?

    Much appreciated!

  2. #2
    Join Date
    May 2006
    Location
    Odenton, MD
    Posts
    1,449
    interesting! don't know what is the use, but msie create a native built-in object named as item, don't know what it contain. so, when you create the variable item as global in the event onclick, msie will throw an error because it seem the object is read-only. the interesting part is if you define the variable with var statement in the global scope, msie don't throw error. but if you do the variable as global (i.e. without the var statement) in the global scope, error is throw.

  3. #3
    Join Date
    Oct 2008
    Posts
    2
    You, Sir, are a true legend!

    Works a treat now. I would have never worked that one out!

    If you were here I'd buy you a drink.

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



Recent Articles