-
-
Save benphelps/931e0b7e4f36f430ba38 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// this goes into every page where the hijack will take place | |
// or where the hijack will land | |
function hijack (abs, landing) { | |
// make sure its actually a #jump= | |
if (window.location.hash.indexOf("#jump=") !== -1) { | |
// trim off jump= and redirect | |
url = window.location.hash.substr(6); | |
window.setTimeout(function(){ | |
window.location = url; | |
}, 2000); | |
} | |
// capture all a href elements and replace with landing | |
var element = document.getElementsByTagName('a'); | |
for (var i = 0; i < element.length; i++) { | |
// check if the url is absolute or not | |
if (element[i].getAttribute('href').indexOf('http') == 0) { | |
element[i]['href'] = landing + element[i].getAttribute('href'); | |
} | |
else { | |
element[i]['href'] = abs + landing + element[i].getAttribute('href'); | |
} | |
} | |
} | |
hijack('http://ncat.edu/', 'ad.html#jump='); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment