hasAttribute method

Determines whether an attribute with the specified name exists.

 

Syntax

HRESULT retVal = object.hasAttribute(name, pfHasAttribute);

Parameters

name [in]

Type: BSTR

BSTR that specifies the name of the attribute.

pfHasAttribute [out, retval]

Type: VARIANT_BOOL

VARIANT_FALSE (false)

The specified attribute does not exist.

VARIANT_TRUE (true)

The specified attribute exists.

Return value

Type: HRESULT

If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Standards information

Remarks

Windows Internet Explorer 8 and later. The IHTMLElement5::hasAttribute method requires IE8 Standards mode and is not supported in IE7 Standards mode or IE5 (Quirks) mode mode. For more information, see Defining Document Compatibility.

The IHTMLElement5::hasAttribute method tests for the existence of an attribute specified by name. The IHTMLElement5::hasAttributes method, on the other hand, determines whether the element has any attributes at all.

See also

Reference

getAttribute

IHTMLElement5::hasAttributes