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 5 of 5
  1. #1
    Regular Coder
    Join Date
    May 2005
    Posts
    100
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Node.prototype to work in IE

    Node.prototype doesn't seem to work in Internet Explorer.

    Is there something else I can use for Node, that works in Internet Explorer 5+ ?

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    What is your final goal, after all? What are u looking after? can u detail a little bit?
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #3
    Regular Coder
    Join Date
    May 2005
    Posts
    100
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Sorry for not providing enough information, this here is my function:


    Code:
    Node.prototype.setAttributes = function()
    {
       for( ar = 0 ; ar < arguments.length ; ar=ar+2 )
       {
          (arguments[ar] == 'class')? this.className = arguments[ar+1]:this.setAttribute(arguments[ar],arguments[ar+1]);
       }
    }
    It would set multiple attributes to a Node on one line, I know it can be done with normal functions, but I just wanted to know if I can do it with prototype.
    The problem here is that Internet Explorer does not define "Node", it works fine in Firefox (don't know about other browsers), so is there anything else I can use instead of "Node" for it to work in Internet Explorer and other browsers?

  • #4
    Regular Coder martin_narg's Avatar
    Join Date
    Jul 2002
    Location
    Chamonix, France
    Posts
    600
    Thanks
    1
    Thanked 3 Times in 3 Posts
    The IE DOM does not allow JavaScript to access the DOM constructors for prototyping and hence HTML element/Node prototyping is not supported by the IE DOM natively, it must be emulated. jkd wrote an interesting article on it here for IE 5.5+: http://blog.codingforums.com/index.p..._55_and_above/

    I would suggest using string manipulation/concatenation to set multiple values to a node attribute, potentially having to use multiline code to do this.

    Edit:
    Or do something like this:
    Code:
    // top level function rather than prototype
    function setElementAttribute(obj, attributeName, attributeValue) {
    	obj.setAttribute(attributeName, attributeValue);
    }
    
    // usage
    setElementAttribute(document.getElementById("elementID"), "customAttribute", "martin_narg 29 London");
    Hope this helps

    m_n
    Last edited by martin_narg; 10-17-2005 at 10:44 PM.
    "Cos it's strange isn't it. You stand in the middle of a library and go 'Aaaaaaaaaaaaaaaaggggggghhhhhhh!'
    and everybody just stares at you. But you do the same in an aeroplane, and everybody joins in."
    -Tommy Cooper

  • #5
    Regular Coder
    Join Date
    May 2005
    Posts
    100
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That's what I was afraid I was going to have to do

    Stupid IE >_>, thanks anyways


  •  

    Posting Permissions

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