共用方式為


AddTag method

Adds an element behavior to a namespace.

Syntax

HRESULT retVal = object.AddTag(bstrTagName, lFlags);

Parameters

bstrTagName [in]

Type: BSTR

The name of the element behavior to add.

lFlags [in]

Type: LONG

A LONG that specifies one of the following ELEMENTDESCRIPTOR_FLAGS enumeration values:

NULL

Default. Creates a usual element behavior.

ELEMENTDESCRIPTORFLAGS_LITERAL

Creates a literal content element behavior.

ELEMENT_DESCRIPTORFLAGS_NESTED_LITERAL

Internet Explorer 6 and later versions, creates a nested literal content element behavior.

Return value

Type: HRESULT

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

Remarks

When MSHTML determines that an object tag in a Web page implements a behavior, it first calls IElementNamespaceFactory::Create, which enables the behavior to add all of its tags to the namespace. MSHTML recognizes each object tag that implements a behavior. When MSHTML encounters a custom element, it can identify which object tag to reference for its implementation.

MSHTML maintains an association between each object tag and its corresponding element behavior, so that several custom tags can be added to a namespace without interference.

In Internet Explorer 6, creates nested literal content element behaviors.

Examples

The following example shows how to add the "MyTag" element behavior to the namespace pointed to by pNamespace.

BSTR bstrTagName = SysAllocString(L"MyTag");
HRESULT hr = pNamespace->AddTag(bstrTagName, 0);
SysFreeString(bstrTagName);