On my page I have some tabs that I’ve added some javascript so when they’re clicked the page loads the tab’s anchor URL instead of simply changing the view with AJAX, but I now want to stop the browser from auto scrolling to the anchor location.
Having done some research, I’m pretty sure I just need to add a couple of lines so that when clicked it returns false or prevents default but, being a noob, I’ve no idea where to put them!?!
I know it’s cheeky, but if any answers could include the full script (ie. the below) with the solution, that way I’ll understand better and hopefully learn some valuable lessons also 🙂
Here’s the code I’m using:
jQuery( function() {
jQuery('.ui-tabs').bind( 'tabsselect', function( e, ui ) {
window.location.hash = ui.tab.hash });
});
The anchor jump happens because it is default behavior. To prevent this from happening you may need to do the following
event.preventDefault()
. I dont know my way around wpui.js but you can always ask in the support forums.Update
OP provides website with problems in comments http://immaga.com/wills
Works in chrome 23.0.1271.91, FF 16.0.1 but not in FF 17.0