Andrew Watson

Navigation

Skip navigation.

Search

Site navigation

Email conversation

FromAndrew Watson
ToMe
SubjectFind-in-page cursor position question
Date8 February 2006 23:44
Hi,

I have found your Find-in-page script very helpful and was wondering if you
could advise me of an easy way to set the cursor to be active in the text
box when the page loads.  And if I am not pushing my luck, is there a way to
clear the text box and keep the active cursor there once the button is
clicked (ready for the next lookup)?

Please keep in mind I am not a fluent programmer….

Thanks

Andrew
FromMe
ToAndrew Watson
SubjectRe: Find-in-page cursor position question
Date9 February 2006 15:55
Andrew,

> I have found your Find-in-page script very helpful and was wondering
> if you could advise me of an easy way to set the cursor to be active
> in the text box when the page loads.

Just a small addition to the script where you create the search field:
if( ( document.body && document.body.createTextRange )|| window.find ) {
...document.write the form here...
document.forms[document.forms.length].elements[0].focus();
}

> is there a way to clear the text box and keep the active cursor
> there once the button is clicked (ready for the next lookup)?

No. If you focus the input after performing a search, then it will remove
the highlight from the text on the page (basically meaning that it will look
like it didn't find anything).


Mark 'Tarquin' Wilton-Jones - author of http://www.howtocreate.co.uk/
FromAndrew Watson
ToMe
SubjectRe: Find-in-page cursor position question
Date10 February 2006 13:28
AttachmentDemo page
Thank you for the fast response,

I am sure that I am missing something here, just not sure what.  I have
attached my code below.  Would it be possible for you to tell what I am
missing.  After I inserted the small addition to the Find in Pare script,
everything sill seem to work correctly, I just could figure out how to tell
the script that I wanted the focus to be in the Find box.

Thanks again...
FromMe
ToAndrew Watson
SubjectRe: Find-in-page cursor position question
Date10 February 2006 15:28
Andrew,

> I am sure that I am missing something here, just not sure what.

no, sorry, it was my fault. the line should have been
document.forms[document.forms.length-1].elements[0].focus();
FromAndrew Watson
ToMe
SubjectRe: Find-in-page cursor position question
Date13 February 2006 12:13
Worked great...

Thank You
This site was created by Mark "Tarquin" Wilton-Jones.
Don't click this link unless you want to be banned from our site.