Hyperlink
This topic describes the API operations that are related to the Hyperlink object of text documents.
Hyperlinks
ActiveDocument.Hyperlinks
Obtains all hyperlinks in the document.
Only JS-SDK V1.1.10 and later support this feature.
Only PCs support this feature.
Syntax
expression.ActiveDocument.Hyperlinksexpression: the document type application object.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain all hyperlinks in the document. const hyperlinks = await app.ActiveDocument.Hyperlinks; }
Methods
ActiveDocument.Hyperlinks.Add()
You can insert a hyperlink by using Add().
Only JS-SDK V1.1.10 and later support this feature.
Only PCs support this feature.
Syntax
expression.ActiveDocument.Hyperlinks.Add({ Address, TextToDisplay })expression: the document type application object.
Parameters
Property
Type
Required
Description
Address
String
Yes
The URL of the hyperlink.
TextToDisplay
String
No
The text of the hyperlink.
Example
async function example() { await instance.ready(); const app = instance.Application; // Insert a hyperlink. await app.ActiveDocument.Hyperlinks.Add({ Address: 'https://www.aliyun.com/', // The URL of the hyperlink. TextToDisplay: 'Alibaba Cloud official website', // The text of the hyperlink. }); }
Properties
ActiveDocument.Hyperlinks.Count
You can obtain the total number of hyperlinks by using Count.
Only JS-SDK V1.1.16 and later versions support this feature.
Syntax
expression.ActiveDocument.Hyperlinks.Countexpression: the document type application object.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the total number of hyperlinks. await app.ActiveDocument.Hyperlinks.Count; }
Hyperlink
ActiveDocument.Hyperlinks.Item()
Obtains a single hyperlink object.
Only JS-SDK V1.1.16 and later support this feature.
Syntax
expression.ActiveDocument.Hyperlinks.Item(Index)expression: the document type application object.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain a single hyperlink object. const shapes = await app.ActiveDocument.Hyperlinks.Item(Index); }
Properties
ActiveDocument.Hyperlinks.Item(Index).Address
You can specify and obtain the URL of a hyperlink by using Address.
Only JS-SDK V1.1.16 and later support this feature.
Syntax
expression.ActiveDocument.Hyperlinks.Item(Index).Addressexpression: the document type application object.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the hyperlink URL. const address = await app.ActiveDocument.Hyperlinks.Item(1).Address }
ActiveDocument.Hyperlinks.Item(Index).TextToDisplay
You can specify and obtain the text of a hyperlink by using TextToDisplay.
Only JS-SDK V1.1.16 and later support this feature.
Syntax
expression.ActiveDocument.Hyperlinks.Item(Index).TextToDisplayexpression: the document type application object.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the text of the hyperlink. const TextToDisplay = await app.ActiveDocument.Hyperlinks.Item(1).TextToDisplay }