JS - To prevent Page scrolling while focusing a particular portion
by barkkathulla[ Edit ] 2013-12-21 10:48:32
How to prevent Page scrolling while focusing a particular location?
part 1:
In your html use the below as a part of a form....
<span id='errormsg' class='err'></span>
<input type="submit" class="button" id = "submit_form" value="submit" />
part 2:
$("#submit_form").click( function() {
$('#errormsg').html("<font color=red>Invalid answer.....</font><br />");
var scr = document.body.scrollTop;
window.location.href = '#';
document.body.scrollTop = scr;
window.location= '#error_msg';
return false;
});