7
A
回答
3
你將不得不依靠javascript來做到這一點,因爲IE5不支持html5自動對焦。這裏有一篇很好的博客文章:http://www.html5tutorial.info/html5-autofocus.php
基本上,你首先檢查屬性是否受支持,然後使用javascript手動對焦使用focus()
方法,如果不是。
-3
自動對焦在IE瀏覽器只是
<input type="text" id="searchbar" autofocus />
不
<input type="text" id="searchbar" autofocus="autofocus"/>
更多信息,請參見http://msdn.microsoft.com/en-us/library/windows/apps/hh441087(v=vs.85).aspx。
2
+0
這是最好的方法,因爲這可以在所有瀏覽器中工作。 – DannyCruzeira
32
這裏是一個一行(當然,實際的邏輯之一線)使用jQuery來使自動對焦工作在IE中。如果焦點已經確定 - 換句話說,在任何支持HTML5的瀏覽器中,它都會被釋放出來。
$(function() {
$('[autofocus]:not(:focus)').eq(0).focus();
});
我解釋了它是如何工作的in my blog。而here是一個更新的jsFiddle在IE中工作。
相關問題
- 1. 在Internet Explorer中自動輸入數據
- 2. 如何讓textarea在Internet Explorer中加載時自動對焦工作
- 3. AngularJS輸入自動對焦
- 4. 如何在IE瀏覽器的自動對焦上進行輸入?
- 5. 如何在Internet Explorer中自動執行鏈接
- 6. 輸入自動對焦屬性
- 7. 使用Internet Explorer進行$(輸入).change時出現的問題
- 8. Jquery自動對焦第二個輸入
- 9. 如何自動在IE(Internet Explorer)上執行「另存爲」?
- 10. 使用VBA輸入事件的Internet Explorer自動化
- 11. 如何在Internet Explorer中運行vbs
- 12. 如何在Internet Explorer中運行fullCalendar?
- 13. 故障自動化Internet Explorer
- 14. 如何在Internet Explorer 6中的輸入框上懸停效果
- 15. ios 10自動對焦不對焦輸入
- 16. Internet Explorer中的輸入文件長度
- 17. 在Internet Explorer中動態創建文件輸入
- 18. HTML5:是自動對焦=「自動對焦」或自動對焦
- 19. 在Internet Explorer中自動調整jQuery UI對話框的大小
- 20. Internet Explorer文本輸入onkeyup char 13
- 21. VBA和Internet Explorer:填寫輸入框
- 22. Internet Explorer表單輸入問題
- 23. jQuery的自動完成功能無法清空在Internet Explorer上輸入
- 24. 如何在Internet Explorer獲得焦點時得到通知
- 25. 在Internet Explorer中輸入文本中的垂直居中文本
- 26. 在Internet Explorer中使用自動對焦時模式中的奇怪光標位置
- 27. 使用Internet Explorer進行調試
- 28. Internet Explorer上的光標焦點問題
- 29. asp.net Internet Explorer窗口焦點故障
- 30. 與在Internet Explorer(浮動)
從今天開始,12/13/2016,autofocus關鍵字在Windows 10的IE 11.0.36中運行,但在Windows 7上的IE 11.0.35中運行。非常令人煩惱。 –