這是我的表單樣本。當頁面加載的焦點必須在'fbox'上,但它的工作量並不明白爲什麼。表單包含niceditor但我不認爲這是問題爲什麼onload焦點在這個腳本上不起作用?
<html>
<head></head>
<body onload="document.form.fbox.focus();">
<body>
<form method='post' action='' name='form' >
Headline <input name='fbox' type='text' class='form' id='box' autocomplete='off' size='80'><br>
Your text</font><br><script type="text/javascript" src="nicEdit.js"></script><script type="text/javascript">bkLib.onDomLoaded(function() { nicEditors.allTextAreas() });</script>
<textarea name="description" style="width: 100%; height:200px;"></textarea></p>
<p><select name='catg' >
<option value='' selected >Select category</option>
</select>
<input type="submit" id='button' name="Submit" value="Submit" class="button"></form>
</body></html>
感謝
它在鉻工作,順便說一句,你知道你必須接受答案?請參閱http://stackoverflow.com/faq#howtoask – Trufa 2011-04-14 14:51:20
Give document.forms [0] .fbox.focus();試試 – used2could 2011-04-14 14:51:29