5

I have two date fields on my Visualforce page and on occasions the datepicker/calendar pops up upon page load. I understand one way to prevent this is to use javascript as suggested below:

<input id="hiddenElementId" type="hidden" />
<script type="text/javascript">
window.onload = setFocus
function setFocus()
{
         document.getElementById("hiddenElementId").focus();
}
</script>

https://developer.salesforce.com/forums?id=906F000000094kJIAQ

However this post is pretty old now, is this still considered the best way to do this?

0

1 Answer 1

15

Please include the snippet below after the page tag.

<apex:page>
    <script>function setFocusOnLoad() {}</script>
    <!-- further content -->
</apex:page>

Hope this will work for you.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .