Skip to content

Instantly share code, notes, and snippets.

@andriasang
Created August 4, 2012 04:09
Show Gist options
  • Save andriasang/3254339 to your computer and use it in GitHub Desktop.
Save andriasang/3254339 to your computer and use it in GitHub Desktop.
window.addEvent('domready', function () {
Behavior.addGlobalFilters ({
LinkHijack: {
defaults: {
"text": "Default Text", // the text you want output
"useAlert": false, // false to use console, true to use alert
"preventDefault": true // true to make hijacked link stop from proceding
},
setup: function (elem, api) {
elem.addEvent ("click", function (e) {
if (api.options.preventDefcault) {
e.preventDefault();
}
if (api.options.type == "alert")
alert (api.options.text);
else
console.log (api.options.text)
}
}
}
});
new Behavior().apply(document.body);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment