Name

Document.createEntityReference( ) — create a new EntityReference node

Availability

DOM Level 1 Core

Synopsis

EntityReference createEntityReference(String name) 
     throws DOMException;

Arguments

name

The name of the referenced entity.

Returns

A new EntityReference node that references an entity with the specified name.

Throws

This method may throw a DOMException with one of the following code values:

INVALID_CHARACTER_ERR

The specified entity name contains an illegal character.

NOT_SUPPORTED_ERR

This is an HTML document and does not support entity references.

Description

This method creates and returns an EntityReference node that refers to an entity with the specified name. Note that it always throws an exception if this is an HTML document, because HTML does not allow entity references. If this document has a DocumentType node, and if that DocumentType defines an Entity object with the specified name, the returned EntityReference has the same children as the referenced Entity node.

Get JavaScript: The Definitive Guide, Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.