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()">
<form method="get" name="g" action="http://www.google.com/search">
<p><input type="text" name="q" size="31" maxlength="255" value="" />
<input type="submit" value="Google Search" /></p></form>
This worked, but when I put it through the W3C validator, it failed because the "name" attribute is no longer used in XHTML 1.0 Strict.
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.