Issue
I got a page with few drop down fields and when I submit the page it returns with a data from mysql just below the fields. I want to make this page positioned to bottom when the user clicks the submit button. Currently I tried the below script:
function md()
{
//window.location.hash="code";
window.scrollTo(0, document.body.scrollHeight);
}
This works in Mozilla, but not in IE. Is there any other alternative for the above code? My submit button has an onclick event which calls two javascript functions:
onClick='selectAllOptions("countryRF");md();return false;'
So in IE while I click its coming to bottom but when data appear its back to top again? Please help me!
Solution
Try using this code:
<form action="" onsubmit="selectAllOptions('countryRF');setTimeout(md, 1000);return false;">
It is better to use onsubmit
for the form
rather than to use onclick
for the button, as people using a keyboard, screenreader, braille terminal etc. won't be able to trigger a click
event.
The code I have added is setTimeout(md, 1000);
, it fires the function md
after 1 second, because the page will probably not take less that a second to update.
EDIT:
That probably won't work.
Try adding name="form"
to your form, and using this in the head
section of your page:
<?php
if(isset($_POST['form'])) {
?>
<script type="text/javascript">
window.onload = function() {
window.scrollTo(0, document.body.scrollHeight);
};
</script>
<?php
}
?>
Answered By - uınbɐɥs
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.