跳到主要内容

SetLink

设置超链接地址。

语法

expression.SetLink(sLink);

expression - 表示 ApiHyperlink 类的变量。

参数

名称必需/可选数据类型默认值描述
sLink必需string超链接地址。

返回值

boolean

示例

更改文档中超链接的 URL。

// How do I update the address a hyperlink points to in a document?

// Point an existing hyperlink to a different website in a document.

let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
let run = Api.CreateRun();
run.AddText("ONLYOFFICE Document Builder");
paragraph.AddElement(run);
let hyperlink = paragraph.AddHyperlink("https://api.onlyoffice.com/docbuilder/basic");
hyperlink.SetLink("https://api.onlyoffice.com/");