Add PWA target blank functionality (#2921)
This commit is contained in:
parent
ae47e8db2c
commit
97125dfd6a
1 changed files with 15 additions and 0 deletions
|
|
@ -15,5 +15,20 @@ function initializePWAFunctionality() {
|
|||
e.preventDefault();
|
||||
window.location.reload();
|
||||
};
|
||||
var isTouchDevice = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|DEV-Native-ios/i.test(navigator.userAgent);
|
||||
if (!isTouchDevice) {
|
||||
var domain = window.location.protocol + '//' + window.location.host
|
||||
var links = document.getElementsByTagName("a");
|
||||
for(var i=0, max=links.length; i<max; i++) {
|
||||
var a = links[i];
|
||||
if (a.href.indexOf(domain + '/') === 0
|
||||
|| a.href.indexOf('/') === 0
|
||||
) {
|
||||
// Is internal link. Do nothing right now.
|
||||
} else {
|
||||
a.setAttribute('target', '_blank');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue