Win a copy of Terraform in Action this week in the Cloud forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Browser automatically scrolls to contact form in footer (undesirable)

 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi fellow ranchers,

I've built a new home page for an existing site, and this includes a simple contact form in the footer.  When the page loads the browser automatically scrolls down to this form, with cursor in the first field.  This obviously isn't desirable.

Plain HTML forms don't normally invoke this behaviour, which has me thinking that some JavaScript may be involved.  Either on the part of Apache Tapestry (the underlying web framework) or Bootstrap which it employs.

If blocking forms from grabbing focus is possible with a simple CSS directive then I've not found it.  What would be the simplest or cleanest solution to this potentially common problem?

Thanking you in advance for any suggestions.

Chris.
 
Saloon Keeper
Posts: 13422
300
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't know Tapestry, and I absolutely despise Bootstrap, so I'm not sure if this will solve your problem, but...

A quick google search indicates that the Form component from Tapestry has an autofocus property that defaults to true. I guess all you need to do is set it to false.
 
Christopher Dodunski
Ranch Hand
Posts: 53
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, my fondness for Bootstrap has waned somewhat also.

You were absolutely correct.  Without autofocus=”false” Tapestry will include some extra JavaScript designed to put the cursor in the first field of the form, causing the browser to scroll to wherever this appears in the page.  So a simple fix in the end. 🙂

Thanks for your help!

Chris.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic