Skip to content

Instantly share code, notes, and snippets.

@pascaldevink
Created October 17, 2013 08:21
Show Gist options
  • Save pascaldevink/7021117 to your computer and use it in GitHub Desktop.
Save pascaldevink/7021117 to your computer and use it in GitHub Desktop.
//we changed this function so you can add a class 'ignore-link' to an element
//this way the click is registered, but not followed
function ns_onclick(i, b, c, h, j) {
var e = "";
if (typeof ns_pixelUrl == "string") {
e = ns_pixelUrl.substring(0, ns_pixelUrl.indexOf("?") + 1)
}
e += c;
e += "&ns_type=" + h + "&ns_action=view";
e += "&ns__t=" + (new Date()).getTime();
if (!b) {
b = i.href
}
var d = document.referrer;
if (d.lastIndexOf("/") == d.length - 1) {
d = d.substring(d.lastIndexOf("/"), 0)
}
if (d.length > 0) {
e += "&ns_referrer=" + escape(d)
}
j = j || "";
var f = (i && i.target && i.target != "") ? (i.target.substring(0, 1) == "_") ? i.target.substring(1) : i.target : "self";
var g = new Image();
var redirect = true;
if ((" " + i.className + " ").replace(/[\n\t]/g, " ").indexOf(" ignore-link ") > -1) {
redirect = false;
}
if (f && b) {
if (window[f]) {
window.ns_softclick_timer = function (k, a) {
return function () {
if (window.ns_softclick_timeout) {
window.clearTimeout(window.ns_softclick_timeout)
}
g.onload = g.onerror = function () {
return
};
window[((window[k]) ? k : "self")].location.href = a
}
}(f, b);
if (redirect) {
ns_softclick_timeout = window.setTimeout("ns_softclick_timer()", 5000);
g.onload = g.onerror = window.ns_softclick_timer
} else {
g.src = e;
return true;
}
} else {
window.open(b, f, j)
}
}
g.src = e;
if (!redirect) {
return true;
} else {
return false;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment