dadamssg87 Posted June 13, 2011 Share Posted June 13, 2011 I know this is really simple but i can' t figure out how to make javascript ignore the url of a link. here is some snippets <div id='previous'><a href='blah.html' onclick='ajaxMonth(7,2011,77)' class='previous_month'> <<</a></div> and then here is my javascript function...i'm using jquery function ajaxMonth(X,Y,Z){ var changemonthlink = "http://localhost:8888/releventz/ajaxcalendar/view/" + X + "/" + Y + "/" + Z; $("#ajaxdiv").load(changemonthlink); return false; }; i thought the "return false;" part would stop the browser from going to the link(blah.html) but it definitely doesn't. If i set the a href="javascript:voide(0);" it works fine but i want to keep the url in there just in case people have javascript blocked. any help would be much appreciated. thanks! Quote Link to comment https://forums.phpfreaks.com/topic/239200-make-browser-ignore-url-of-link/ Share on other sites More sharing options...
RussellReal Posted June 13, 2011 Share Posted June 13, 2011 event.preventDefault(); should work for you.. however, you could also on the onClick="" do this: onClick="return AJAXMonth()" but event.preventDefault is more or less cross browser.. Quote Link to comment https://forums.phpfreaks.com/topic/239200-make-browser-ignore-url-of-link/#findComment-1228986 Share on other sites More sharing options...
Adam Posted June 13, 2011 Share Posted June 13, 2011 but event.preventDefault is more or less cross browser.. IE6, and I believe 7, do not natively support event.preventDefault. Quote Link to comment https://forums.phpfreaks.com/topic/239200-make-browser-ignore-url-of-link/#findComment-1229039 Share on other sites More sharing options...
RussellReal Posted June 13, 2011 Share Posted June 13, 2011 but event.preventDefault is more or less cross browser.. IE6, and I believe 7, do not natively support event.preventDefault. You're probably right, so use the return false and event.prevent default together. Quote Link to comment https://forums.phpfreaks.com/topic/239200-make-browser-ignore-url-of-link/#findComment-1229340 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.