navigator: added option to not open links in new tab
This commit is contained in:
parent
85a43f07a4
commit
bcd94f7bb0
|
@ -1,5 +1,8 @@
|
|||
|
||||
xrf.navigator = {
|
||||
opts: {
|
||||
openInNewTab: true
|
||||
},
|
||||
URI: xrf.URI.parse(document.location.href)
|
||||
// scheme: document.location.protocol.replace(/:$/,''),
|
||||
// directory: document.location.pathname,
|
||||
|
@ -134,7 +137,12 @@ xrf.navigator.setupNavigateFallbacks = () => {
|
|||
if( url.match(/^http/) && url != xrf.navigator.URI.URN && !xrf.loaders[fileExt] ){
|
||||
let inIframe
|
||||
try { inIframe = window.self !== window.top; } catch (e) { inIframe = true; }
|
||||
return inIframe ? window.parent.postMessage({ url }, '*') : window.open( url, '_blank')
|
||||
if( inIframe ){
|
||||
window.parent.postMessage({ url }, '*')
|
||||
}else{
|
||||
if( xrf.navigator.opts.openInNewTab ) window.open( url, '_blank')
|
||||
else{ setTimeout( () => document.location.href = url, 1000) }
|
||||
}
|
||||
// in case you're running in an iframe, then use this in the parent page:
|
||||
//
|
||||
// window.addEventListener("message", (e) => {
|
||||
|
|
Loading…
Reference in New Issue