Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

7
  • 2
    and furthermore, it appears after the last setAttribute in your example, node.frameborder is NOT defined, so you must getAttribute to get the value back. Commented Jan 10, 2014 at 18:35
  • 8
    @Michael correct - if you use setAttribute to set a value, you must use getAttribute to retrieve it. Commented Feb 24, 2014 at 12:22
  • 9
    There is nothing wrong with setting frameBorder directly, but note the capitalization. Someone thought it was a jolly good idea to camelCase the JavaScript equivalents of HTML attributes. I haven't managed to find any specification for this, but the net seems to agree that it is a matter of 12 specific cases (for HTML 4 at least). See for instance the following post: drupal.org/node/1420706#comment-6423420 Commented Jul 31, 2014 at 13:01
  • 1
    The usemap attribute can't be set using the dot notation when creating the map dynamically for an image. It requires img.setAttribute('usemap', "#MapName"); Does your answer imply that usemap is therefore "non-standard"? Commented Feb 17, 2016 at 5:22
  • 1
    This mostly wrong. Some attributes has properties defined, so do not. It's really just about how they wrote the spec. It's has nothing to to due with the attributes being standard or not. However, it is true that none-standard properties can only be accessed with getAttribute(). Commented Apr 12, 2016 at 19:02