Focus input when Fancybox loads

605 views
Skip to first unread message

emosewami

unread,
Sep 25, 2009, 2:20:47 PM9/25/09
to fancybox
I'm having a hard time getting this to work... seems like it should be
easy enough. I have a fancybox that pops up a simple form. I want the
first field in that form to get focus (ie, automatically put the
cursor there for the user) whenever the fancybox is loaded (which is
done by clicking a simple link. Sounds easy, but nothing I have tried
has worked. Has anyone done successfully or are there any other ideas?
Thanks!

JFK

unread,
Sep 25, 2009, 3:57:39 PM9/25/09
to fancybox
every time I link to a form in a different page (even before using
fancybox) the new page with the form will never get focus on the first
field.
i.e this link goes to one of my preferred contact forms
http://green-beast.com/gbcf-v3/test-form.php
click on the link and you'll see the first field doesn't get focus,
even if you manually select it and then reload the page, you'll miss
the focus. this is not an issue related to fancybox; if you can
eventually get what you want in a simple form page then you will get
it in fancybox

WilzDezign

unread,
Sep 27, 2009, 10:42:37 PM9/27/09
to fancybox
With basic javascript, you can tell a form field to get focus:

document.getElementById('formFieldIDtoGetFocus').focus();

You can put this on your web page javascript to get the current form
field focus. However if using jQuery, the field and inline is shown
after click... so the focus() must be triggered with the jQuery/
fancybox pop-up

On Sep 25, 12:57 pm, JFK <jfk.d...@gmail.com> wrote:
> every time I link to a form in a different page (even before using
> fancybox) the new page with the form will never get focus on the first
> field.
> i.e this link goes to one of my preferred contact formshttp://green-beast.com/gbcf-v3/test-form.php

JFK

unread,
Sep 28, 2009, 3:17:45 AM9/28/09
to fancybox
then use the callbackOnStart option to trigger the function

Iain

unread,
Oct 6, 2009, 4:22:26 PM10/6/09
to fancybox
Could someone give me a pointer towards getting this right?

I'm VERY new to jQuery and struggling to get this focus working... how
would I use the callbackOnStart to give my form the focus?
Reply all
Reply to author
Forward
0 new messages