I'm customizing a website that was build by someone else using a WYSIWYG. I'm stuck with an href having javascript in it.
How can I, onClick of this anchor tag, capture the href, change it's value to #, preventDefault, and then actually run what was going to originally be ran? I know this is a bit odd, but it's currently causing IE errors and I believe it will fix it.
HTML:
<a class="cpMonthNavigation" href="javascript:CP_refreshCalendar(3,1,2012);"><<</a>
jQuery:
$(document).click({namespace: this}, function (e) {
var t = e.data.namespace;
if ($(e.target).is($(".cpMonthNavigation"))) {
e.preventDefault();
$(e.target).attr("href").replace(/javascript:/i, "");
// This is where I need to manually run the function that was in the HREF
}
}
Please keep in mind that I cannot edit the HTML. I'm stuck with it and it's terrible-ness.
I need to preventDefault so that the vendor code does not run but still run what's actually in the href. There are multiple things behind the scenes in the vendor code bound to the click of this anchor.