Skip to main content

Hyperlink

// Gets URLs of all hyperlinks in the main sub-document
var hyperlinks = richEdit.document.hyperlinks;
var hyperlinkUrls = [];
for(var i = 0, hyperlink; hyperlink = hyperlinks.getByIndex(i); i++)
    if (hyperlink.hyperlinkInfo.url)
        hyperlinkUrls.push(hyperlink.hyperlinkInfo.url);
var text = 'Go to Google';
var url = 'https://www.google.com/';
var hyperlinkInfo = new DevExpress.RichEdit.HyperlinkInfo(text, url, undefined, 'tooltip');
richEdit.selection.activeSubDocument.hyperlinks.create(richEdit.selection.active, hyperlinkInfo);
var subDocument = richEdit.selection.activeSubDocument;
var currentPosition = richEdit.selection.active;
// Creates a bookmark at the current position
subDocument.insertText(currentPosition, 'Some text');
var interval = new DevExpress.RichEdit.Interval(currentPosition, 'Some text'.length);
var bkm = subDocument.bookmarks.create(interval, 'bkmName');
// Creates a hyperlink to the bookmark at the end of the active sub-document
var hyperlinkInfo = new DevExpress.RichEdit.HyperlinkInfo('Go to Bookmark', undefined, bkm.name, 'tooltip');
var hyperlink = subDocument.hyperlinks.create(subDocument.length - 1, hyperlinkInfo);