Add PWA target blank functionality (#2921)

This commit is contained in:
Ben Halpern 2019-05-21 13:15:36 -04:00 committed by GitHub
parent ae47e8db2c
commit 97125dfd6a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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');
}
}
}
}
}