mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-04-27 03:00:12 -04:00
Only use window.open on http links
This commit is contained in:
@@ -35,14 +35,18 @@ r.ui.init = function() {
|
||||
if (r.config.new_window && (r.config.logged || !smallScreen)) {
|
||||
$(document.body).on('click', 'a.may-blank, .may-blank-within a', function(e) {
|
||||
if (!this.target) {
|
||||
// nullify `window.opener` so the new tab can't navigate us
|
||||
var href = $(this).attr('href');
|
||||
var w = window.open(null, '_blank');
|
||||
w.opener = null;
|
||||
w.location.href = href;
|
||||
// suppress normal link opening behaviour
|
||||
e.preventDefault();
|
||||
return false;
|
||||
var proto = this.protocol;
|
||||
if (this.href && (proto === "http:" || proto === "https:")) {
|
||||
// nullify `window.opener` so the new tab can't navigate us
|
||||
var href = $(this).attr('href');
|
||||
var w = window.open(null, '_blank');
|
||||
w.opener = null;
|
||||
w.location.href = href;
|
||||
// suppress normal link opening behaviour
|
||||
e.preventDefault();
|
||||
return false;
|
||||
}
|
||||
this.target = "_blank";
|
||||
}
|
||||
return true; // continue bubbling
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user