unemployment Posted May 9, 2011 Share Posted May 9, 2011 I am loading a link with ajax. When the link pops on the screen and I click it, I get redirected to my 404 page and my lightbox doesn't load. If the link pops in and I refresh my browser, then I click the link my lightbox will show up. How can I do a prevent default on the <a href> in pure JS? No frameworks please. Link to comment https://forums.phpfreaks.com/topic/235957-prevent-default/ Share on other sites More sharing options...
requinix Posted May 9, 2011 Share Posted May 9, 2011 Don't use an href. Or point to # or javascript:; or somesuch. But if you must modify onclick, return false; from it. If you use a listener there are a couple event methods to check out (preventDefault and stopPropagation I think). Link to comment https://forums.phpfreaks.com/topic/235957-prevent-default/#findComment-1213045 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.