mirror of
https://github.com/tcsenpai/Zundler.git
synced 2025-06-06 11:35:40 +00:00
Fix fixLinks
Don't touch links starting with `javascript:`
This commit is contained in:
parent
76f8976646
commit
6648b5e619
@ -44,14 +44,18 @@ var splitUrl = function(url) {
|
|||||||
|
|
||||||
|
|
||||||
var fixLink = function(a) {
|
var fixLink = function(a) {
|
||||||
if (isVirtual(a.getAttribute('href'))) {
|
const href = a.getAttribute("href");
|
||||||
|
if (isVirtual(href)) {
|
||||||
// virtualClick will be defined in the iFrame, but fixLink may be
|
// virtualClick will be defined in the iFrame, but fixLink may be
|
||||||
// called in the parent document, so we use `onclick`, because we
|
// called in the parent document, so we use `onclick`, because we
|
||||||
// can define the function as a string
|
// can define the function as a string
|
||||||
a.setAttribute("onclick", "virtualClick(event)");
|
a.setAttribute("onclick", "virtualClick(event)");
|
||||||
} else if (a.getAttribute('href').startsWith('#')) {
|
} else if (href.startsWith('#')) {
|
||||||
a.setAttribute('href', "about:srcdoc" + a.getAttribute('href'))
|
a.setAttribute('href', "about:srcdoc" + a.getAttribute('href'))
|
||||||
} else if (!a.getAttribute('href').startsWith('about:srcdoc')) {
|
} else if (
|
||||||
|
!href.startsWith('about:srcdoc')
|
||||||
|
&& !href.startsWith('javascript:')
|
||||||
|
) {
|
||||||
// External links should open in a new tab. Browsers block links to
|
// External links should open in a new tab. Browsers block links to
|
||||||
// sites of different origin within an iframe for security reasons.
|
// sites of different origin within an iframe for security reasons.
|
||||||
a.setAttribute('target', "_blank");
|
a.setAttribute('target', "_blank");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user