2014-03-05 51 views
3

我有一個Web應用程序(而非Android應用)失去焦點textarea的當鍵盤出現

我有很多的textarea在我的網頁像例如波紋管,如果我點擊在iPad上的textarea的keyborad出現,我失去焦點在我的textarea。

我的問題:即使密鑰顯示,我如何保持焦點?無需使用jQuery手機。

爲例

<html> 
    <head> 
     <title>My Page</title> 
    </head> 

    <body> 
     <form name="myform" action="" method="POST"> 
      <div align="center"> 
       This is outside the area<br><br> 
       <textarea cols="40" rows="1" name="myname"> 
         Now we are inside the area - which is nice. 
       </textarea> 
       <br><br> 
       And now we are outside the area again. 
      </div> 
      <div align="center"> 
       This is outside the area<br><br> 
       <textarea cols="40" rows="1" name="myname"> 
         Now we are inside the area - which is nice. 
       </textarea> 
       <br><br> 
       And now we are outside the area again. 
      </div> 
      <div align="center"> 
       This is outside the area<br><br> 
       <textarea cols="40" rows="1" name="myname"> 
         Now we are inside the area - which is nice. 
       </textarea> 
       <br><br> 
       And now we are outside the area again. 
      </div> 
     </form> 
    </body> 
</html> 
+0

那麼你爲什麼用Android標籤標記這個問題? – Kedarnath

+0

從問題 –

+0

中刪除android標記,因爲它與android相關的問題 –

回答

0

你可以嘗試HTML 自動對焦屬性:

<textarea cols="40" rows="1" name="myname" autofocus> 
    Now we are inside the area - which is nice. 
</textarea> 

不知道onclick="autofocus"作品順便說一句。 (不相信它,你將需要JavaScript)