Jaa


removeAttribute method

Removes an attribute from an object.

 

Syntax

 retVal = object.removeAttribute(strAttributeName, lFlags);

Parameters

strAttributeName [in]

Type: BSTR

BSTR that specifies an attribute name.

lFlags [in, optional]

Type: long

LONG that specifies whether to use a case-sensitive search to locate the attribute. Can be one of the following values:

1

The case of strAttributeName is respected.

0

Match strAttributeName regardless of case.

Standards information

Remarks

Windows Internet Explorer 8 and later. IE8 Standards mode enables several enhancements to the IHTMLElement::setAttribute, IHTMLElement::getAttribute, and IHTMLElement::removeAttribute methods that are not available when pages are displayed in earlier document modes:

  • The strAttributeName parameter requires the name of the desired content attribute and not the Document Object Model (DOM) attribute. For example, in IE8 mode, this method no longer requires strAttributeName to be "className" when setting, getting, or removing a IHTMLElement::className attribute. Earlier versions of Windows Internet Explorer and Internet Explorer 8 in compatibility mode still require strAttributeName to specify the corresponding DOM property name.

  • The strAttributeName parameter is not case sensitive. As a result, the lFlags parameter is no longer supported and should not be used.

  • The methods support event handlers. For example, the following code example defines an event handler to call a function called SomeFunction when the body of the page is loaded.

    document.body.setAttribute('onload', 'SomeFunction()');
    

IHTMLElement::removeAttribute always returns S_OK as an HRESULT value. Check the pfSuccess parameter to determine if the attribute is successfully removed.

If your pages are displayed in IE5 (Quirks) mode or IE7 Standards mode, be careful when spelling attribute names. If two or more attributes have the same name—differing only in capitalization—and lFlags is set to 0, this method removes only the last attribute to be created with this name. All other attributes of the same name are ignored.

The strAttributeName parameter requires the name of the desired content attribute and not the DOM attribute.

The strAttributeName parameter is not case sensitive. As a result, the lFlags parameter is no longer supported and should not be used.

The methods support event handlers. For example, the following code example defines an event handler to call a function called SomeFunction when the body of the page is loaded.

document.body.setAttribute('onload', 'SomeFunction()');

IHTMLElement::removeAttribute always returns S_OK as an HRESULT value. Check the pfSuccess parameter to determine if the attribute is successfully removed.

See also

Reference

IHTMLElement::getAttribute

IHTMLElement::setAttribute