XHTML Strict and input field focus
OK, I know this is not programming, but I couldn't think of where else to put this. I am building myself a custom homepage to learn XHTML and CSS. I am trying to to make my Google search box automatically gain focus when the page loads.
I tried this: Code:
<body onload="document.g.q.focus()"> I also tried to change the name="g" to id="g", as id is supposedly the replacement for name, but it didn't work. I also tried to use getElementByID(), but if I change name="q" to id="q", the google search doesn't work, and leaves me at Google.com. Another thing I tries was to give them both the name and id attributes, which also didn't work. Curiously, if I have "name" in the <form> element, validation fails as name is deprecated in XHTML 1.0 Strict, but "name in the <input> element passes no problem. |
How about this:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" Works right and validates, too. |
Excellent, thanks very much taylor_venable, it works perfectly.
Now I just need to fill up my popup menus with loads of links. Thank you again. |
All times are GMT -5. The time now is 04:10 AM. |