English 中文(简体)
如何通过javascript或jquery将一个投入领域集中到Andrew browser
原标题:How to focus an input field on Android browser through javascript or jquery

I ve tried $( #field ).focus(), and any other method found on the internet. Nothing worked. I have a simple html that reproduces the problem.

<!DOCTYPE html> 
<html> 
    <head> 
        <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
        <script type="text/javascript">
            $(document).ready(function() {
                $( #field ).focus();
            });
    </script>
</head> 
<body>
    <input type="text" id="field" name="field"/>
</body>
</html>

Please help!

最佳回答

实际上,一般javascript功能“focus”在刺.器中被拆除。 因此,由于使用了上述功能, j子的重心功能已经停止。

问题回答

if you bind it to another click event it will work. This works for me:

    $(document).ready(function()
    {

       $( #field ).click(function(e){ $(this).focus(); });

            $( body ).click(function(e)
            {
                $( #field ).trigger( click );
            })
    })   

将登上软件键盘。 触发任何事件。 在这种情况下,现场点击的违约行为=主线=焦点=赢! 注:这一呼吁必定会发生另一个点击事件。

var target = document.getElementsByTagName("input")[0];

if (event.target != target) {
    target.focus();
    target.click();
}




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签