Skip to content

Instantly share code, notes, and snippets.

@fukusaka
Created April 18, 2010 18:25
Show Gist options
  • Save fukusaka/370450 to your computer and use it in GitHub Desktop.
Save fukusaka/370450 to your computer and use it in GitHub Desktop.
//
// cut referer
//
function cutreferer(objLink)
{
var url = objLink.href;
var isMSIE = /*@cc_on!@*/false;
if (isMSIE) {
location.href = url;
} else {
//var data = '<html><script>location.replace("'+url+'");</script></html>';
var data = '<html><head><meta http-equiv="refresh" content="0;url='+url+'" /></head></html>';
location.href="data:text/html;charset=utf-8,"+encodeURIComponent(data);
}
}
function initcutreferer()
{
if (!document.getElementsByTagName){ return; }
var anchors = document.getElementsByTagName("a");
// loop through all anchor tags
for (var i=0; i<anchors.length; i++){
var anchor = anchors[i];
if (!anchor.getAttribute("href")) { continue; }
var className = anchor.getAttribute("class")||anchor.getAttribute("className")
if (className != "exteranl") { continue; }
anchor.onclick = function () {cutreferer(this); return false;}
}
}
function addLoadEvent(func)
{
var oldonload = window.onload;
if (typeof window.onload != 'function'){
window.onload = func;
} else {
window.onload = function(){
oldonload();
func();
}
}
}
// Initialize after loading the page
addLoadEvent(initcutreferer)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment