Working with Hyperlinks
URL hyperlinks
URL hyperlinks on text
To apply URL hyperlinks on text:
-
Get the DOM of the active layout.
-
Get the desired
<qx-box>,<qx-p>and<qx-span>node . -
Create the element
<qx-a>and set its 'href' attribute to 'www.google.com' and 'title' attribute to 'google'. -
Append the span inside the newly created
<qx-a>. -
Append the
<qx-a>inside the paragraph.var layout=app.activeLayoutDOM(); var boxes=layout.getElementsByTagName('qx-box'); var paras = boxes[0].getElementsByTagName('qx-p'); var spans=boxes[0].getElementsByTagName('qx-span'); var url_anchor=document.createElement('qx-a'); url_anchor.setAttribute('href','www.google.com'); url_anchor.setAttribute('title','google'); url_anchor.appendChild(spans[0]); paras[0].appendChild(url_anchor);
URL hyperlinks on box
To apply URL hyperlinks on box:
-
Get the DOM of the active layout.
-
Get the desired
<qx-spread>and<qx-box>node . -
Create the element
<qx-a>and set its 'href' attribute to 'www.google.com' and 'title' attribute to 'google'. -
Append the box inside the newly created
<qx-a>. -
Append the
<qx-a>inside the spread.var layout=app.activeLayoutDOM(); var spreads=layout.getElementsByTagName('qx-spread'); var boxes=layout.getElementsByTagName('qx-box'); var url_anchor=document.createElement('qx-a'); url_anchor.setAttribute('href','www.google.com'); url_anchor.setAttribute('title','google'); url_anchor.appendChild(boxes[0]); spreads[0].appendChild(url_anchor);
Anchor hyperlinks
Creating new anchor
To create a new anchor:
-
et the DOM of the active layout.
-
Get the desired
<qx-box>and<qx-p>node . -
Create the element
<qx-bookmark>and set its 'id' attribute to 'anchor'. -
Create the element
<qx-span>and set its inner text to 'NEW BOOKMARK'. -
Append the bookmark inside the paragraph.
-
Append the span inside the paragraph.
var layout = app.activeLayoutDOM(); var boxes = layout.getElementsByTagName('qx-box'); var paras= boxes[0].getElementsByTagName('qx-p'); var new_bookmark=document.createElement('qx-bookmark'); new_bookmark.setAttribute('id','anchor'); var new_span=document.createElement('qx-span'); new_span.innerText='NEW BOOKMARK'; paras[0].appendChild(new_bookmark); paras[0].appendChild(new_span);
Anchor hyperlinks on text
To apply anchor hyperlinks on text:
-
Get the DOM of the active layout.
-
Get the desired
<qx-box>,<qx-p>and<qx-span>node . -
Create a new bookmark as mentioned in the above section.
-
Create the element
<qx-a>and set its 'href' attribute to the id of the bookmark. -
Append the span inside the newly created
<qx-a>. -
Append the
<qx-a>inside the paragraph.
var layout = app.activeLayoutDOM();
var boxes = layout.getElementsByTagName('qx-box');
var paras=boxes[0].getElementsByTagName('qx-p');
var spans=paras[0].getElementsByTagName('qx-span');
var anchor_span=boxes[1].getElementsByTagName('qx-span');
anchor_span[0].innerHTML='I am Anchor for Box 1';
var new_bookmark=document.createElement('qx-bookmark');
new_bookmark.setAttribute('id','anchor');
var list=anchor_span[0].parentNode;
list.insertBefore(new_bookmark,list.childNodes[0]);
var new_anchor_url=document.createElement('qx-a');
new_anchor_url.setAttribute('href','#anchor');
new_anchor_url.appendChild(spans[0]);
paras[0].appendChild(new_anchor_url);
Page hyperlinks
Page hyperlinks on text
To apply page hyperlinks on text:
-
Get the DOM of the active layout.
-
Get the desired
<qx-box>,<qx-p>and<qx-span>node . -
Create the element
<qx-a>and set its 'href' attribute to '#page=2'. -
Append the span inside the newly created
<qx-a>. -
Append the
<qx-a>inside the paragraph.var layout=app.activeLayoutDOM(); var boxes=layout.getElementsByTagName('qx-box'); var paras = boxes[0].getElementsByTagName('qx-p'); var spans=boxes[0].getElementsByTagName('qx-span'); var page_anchor=document.createElement('qx-a'); page_anchor.setAttribute('href','#page=2'); page_anchor.appendChild(spans[0]); paras[0].appendChild(page_anchor);
Page hyperlinks on box
To apply page hyperlinks on box:
-
Get the DOM of the active layout.
-
Get the desired
<qx-spread>and<qx-box>node . -
Create the element
<qx-a>and set its 'href' attribute to '#page=2'. -
Append the box inside the newly created
<qx-a>. -
Append the
<qx-a>inside the spread.
var layout=app.activeLayoutDOM();
var spreads=layout.getElementsByTagName('qx-spread');
var boxes=layout.getElementsByTagName('qx-box');
var page_anchor=document.createElement('qx-a');
page_anchor.setAttribute('href','#page=2');
page_anchor.appendChild(boxes[0]);
spreads[0].appendChild(page_anchor);