Try to deal with non-W3C compliant popup blockers

This commit is contained in:
Jordan Milne
2014-12-19 03:05:40 -04:00
parent 95a2d12aab
commit 1e660d07f7

View File

@@ -42,14 +42,22 @@ r.ui.init = function() {
var isWebLink = _.contains(['http:', 'https:'], this.protocol);
if (this.href && isWebLink && !r.utils.onIEMobile()) {
var w = window.open('', '_blank');
w.opener = null;
w.location.href = href;
// suppress normal link opening behaviour
e.preventDefault();
return false;
// some popup blockers appear to return null for
// `window.open` even inside click handlers.
if (w !== null) {
// try to nullify `window.opener` so the new tab can't
// navigate us
w.opener = null;
w.location.href = this.href;
// suppress normal link opening behaviour
e.preventDefault();
return false;
}
}
this.target = "_blank";
}
return true; // continue bubbling
})
}