max401 is offlineAdd to max401's Reputation
max401's Avatar
max401
Pilot Light
Join Date: Nov 2008
Posts: 211

Focus a cursor in the search field

POSTED BY: max401 3 weeks, 2 days ago

Ive just designed a webstie and the main area is a search box, how do i make the cursor go straight to the search box ready to type when page loads, like google for example...

thanks

Tags: (Add a tag)



Benjimoron is offline  
Benjimoron
Solar Flare
Benjimoron is getting a little spicyBenjimoron is getting a little spicyBenjimoron is getting a little spicyBenjimoron is getting a little spicyBenjimoron is getting a little spicyBenjimoron is getting a little spicyBenjimoron is getting a little spicyBenjimoron is getting a little spicyBenjimoron is getting a little spicyBenjimoron is getting a little spicyBenjimoron is getting a little spicy
 
Join Date: Sep 2006
Posts: 10,082
View FS/FT Feedback
check google's html?

Maybe something like this?

"onload="document.f.q.focus()"
Reply With Quote
max401 is offline  
max401's Avatar
max401
Pilot Light
max401 has a spectacular aura aboutmax401 has a spectacular aura about
 
Join Date: Nov 2008
Location: Swansea
Posts: 211
View FS/FT Feedback
do i put that before /head?
Reply With Quote
Benjimoron is offline  
Benjimoron
Solar Flare
Benjimoron is getting a little spicyBenjimoron is getting a little spicyBenjimoron is getting a little spicyBenjimoron is getting a little spicyBenjimoron is getting a little spicyBenjimoron is getting a little spicyBenjimoron is getting a little spicyBenjimoron is getting a little spicyBenjimoron is getting a little spicyBenjimoron is getting a little spicyBenjimoron is getting a little spicy
 
Join Date: Sep 2006
Posts: 10,082
View FS/FT Feedback
max401:
do i put that before /head?
I don't have a clue mate, that's the bit from google's page which looks most likely but you need someone that knows what they're doing. I probably could've worked this out 10 years ago but not anymore!
Reply With Quote
catinthehat is offline  
catinthehat's Avatar
catinthehat
Solar Flare
catinthehat has a brilliant futurecatinthehat has a brilliant futurecatinthehat has a brilliant futurecatinthehat has a brilliant futurecatinthehat has a brilliant futurecatinthehat has a brilliant futurecatinthehat has a brilliant futurecatinthehat has a brilliant futurecatinthehat has a brilliant futurecatinthehat has a brilliant futurecatinthehat has a brilliant future
 
Join Date: Jun 2008
Posts: 1,141
View FS/FT Feedback
there is a bit about it here, might help, might not.
Reply With Quote
catinthehat is offline  
catinthehat's Avatar
catinthehat
Solar Flare
catinthehat has a brilliant futurecatinthehat has a brilliant futurecatinthehat has a brilliant futurecatinthehat has a brilliant futurecatinthehat has a brilliant futurecatinthehat has a brilliant futurecatinthehat has a brilliant futurecatinthehat has a brilliant futurecatinthehat has a brilliant futurecatinthehat has a brilliant futurecatinthehat has a brilliant future
 
Join Date: Jun 2008
Posts: 1,141
View FS/FT Feedback
catinthehat:
there is a bit about it here, might help, might not.
.........although its for forms, so might not.
Reply With Quote
max401 is offline  
max401's Avatar
max401
Pilot Light
max401 has a spectacular aura aboutmax401 has a spectacular aura about
 
Join Date: Nov 2008
Location: Swansea
Posts: 211
View FS/FT Feedback
cant seem to get it working with any of them/... this is my input field and button...

<input type="hidden" name="cx" value="partner-pubxxxxxxxxxxxxxxxxxxxxxxxxxwxxxg-xxl2" />
<input type="hidden" name="ie" value="ISO-xxxx-1" />
<input type="text" name="q" size="60" />
<input type="submit" name="sa" value="Chwilio" />
<input name="reason" type="radio" checked>
Reply With Quote
Benjimoron is offline  
Benjimoron
Solar Flare
Benjimoron is getting a little spicyBenjimoron is getting a little spicyBenjimoron is getting a little spicyBenjimoron is getting a little spicyBenjimoron is getting a little spicyBenjimoron is getting a little spicyBenjimoron is getting a little spicyBenjimoron is getting a little spicyBenjimoron is getting a little spicyBenjimoron is getting a little spicyBenjimoron is getting a little spicy
 
Join Date: Sep 2006
Posts: 10,082
View FS/FT Feedback
Maybe the smiley in there is causing the problem???
Reply With Quote
Benjimoron is offline  
Benjimoron
Solar Flare
Benjimoron is getting a little spicyBenjimoron is getting a little spicyBenjimoron is getting a little spicyBenjimoron is getting a little spicyBenjimoron is getting a little spicyBenjimoron is getting a little spicyBenjimoron is getting a little spicyBenjimoron is getting a little spicyBenjimoron is getting a little spicyBenjimoron is getting a little spicyBenjimoron is getting a little spicy
 
Join Date: Sep 2006
Posts: 10,082
View FS/FT Feedback
<!-- TWO STEPS TO INSTALL FOCUS ONLOAD:

1. Add the onLoad event handler into the BODY tag
2. Copy the coding into the BODY of your HTML document -->

<!-- STEP TWO: Insert the onLoad event handler into your BODY tag -->

<BODY OnLoad="document.nameform.user.focus();"><!-- STEP ONE: Paste this code into the BODY of your HTML document -->



<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<center>
<form name="nameform">
Name: <input type=text name=user size=10>
</form>
</center>

<p><center>
<font face="arial, helvetica" size="-2">Free JavaScripts provided<br>
by <a href="http://javascriptsource.com">The JavaScript Source</a></font>
</center><p>

<!-- Script Size: 0.61 KB -->
Reply With Quote
Ambdon is offline  
Ambdon's Avatar
Ambdon
Pilot Light
Ambdon has a brilliant futureAmbdon has a brilliant futureAmbdon has a brilliant futureAmbdon has a brilliant futureAmbdon has a brilliant futureAmbdon has a brilliant futureAmbdon has a brilliant futureAmbdon has a brilliant futureAmbdon has a brilliant futureAmbdon has a brilliant futureAmbdon has a brilliant future
 
Join Date: May 2008
Posts: 229
View FS/FT Feedback
You haven't told us your form name, so replace YOURFORM with the name of your form!

<body onload="document.YOURFORM.q.focus()">

<form name="YOURFORM">
<input type="hidden" name="cx" value="partner-pubxxxxxxxxxxxxxxxxxxxxxxxxxwxxxg-xxl2" />
<input type="hidden" name="ie" value="ISO-xxxx-1" />
<input type="text" name="q" size="60" />
<input type="submit" name="sa" value="Chwilio" />
<input name="reason" type="radio" checked>
</form>

</body>
Reply With Quote
max401 is offline  
max401's Avatar
max401
Pilot Light
max401 has a spectacular aura aboutmax401 has a spectacular aura about
 
Join Date: Nov 2008
Location: Swansea
Posts: 211
View FS/FT Feedback
Ambdon:
You haven't told us your form name, so replace YOURFORM with the name of your form!

</body>
is this it?

<form action="http://www.google.co.uk/cse" id="cse-search-box">

and the id is the form name?
Reply With Quote
Benjimoron is offline  
Benjimoron
Solar Flare
Benjimoron is getting a little spicyBenjimoron is getting a little spicyBenjimoron is getting a little spicyBenjimoron is getting a little spicyBenjimoron is getting a little spicyBenjimoron is getting a little spicyBenjimoron is getting a little spicyBenjimoron is getting a little spicyBenjimoron is getting a little spicyBenjimoron is getting a little spicyBenjimoron is getting a little spicy
 
Join Date: Sep 2006
Posts: 10,082
View FS/FT Feedback
Benjimoron:
<!-- TWO STEPS TO INSTALL FOCUS ONLOAD:

1. Add the onLoad event handler into the BODY tag
2. Copy the coding into the BODY of your HTML document -->

<!-- STEP TWO: Insert the onLoad event handler into your BODY tag -->

<BODY OnLoad="document.nameform.user.focus();"><!-- STEP ONE: Paste this code into the BODY of your HTML document -->



<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<center>
<form name="nameform">
Name: <input type=text name=user size=10>
</form>
</center>

<p><center>
<font face="arial, helvetica" size="-2">Free JavaScripts provided<br>
by <a href="http://javascriptsource.com">The JavaScript Source</a></font>
</center><p>

<!-- Script Size: 0.61 KB -->
Why don't you just use that???
Reply With Quote
Ambdon is offline  
Ambdon's Avatar
Ambdon
Pilot Light
Ambdon has a brilliant futureAmbdon has a brilliant futureAmbdon has a brilliant futureAmbdon has a brilliant futureAmbdon has a brilliant futureAmbdon has a brilliant futureAmbdon has a brilliant futureAmbdon has a brilliant futureAmbdon has a brilliant futureAmbdon has a brilliant futureAmbdon has a brilliant future
 
Join Date: May 2008
Posts: 229
View FS/FT Feedback
max401:
is this it?

<form action="http://www.google.co.uk/cse" id="cse-search-box">

and the id is the form name?
Try changing it to:

<form action="http://www.google.co.uk/cse" id="cse-search-box" name="myform">

and then adding:
<body onload="document.myform.q.focus()">
Reply With Quote