相关疑难解决方法(0)

自动对焦当通过Ajax加载<Form> <input>时,HTML5的属性不仅适用于FireFox.为什么?

下面是我通过ajax加载的表单.当我直接运行表单页面然后自动对焦c_name在Firefox中工作但是当加载ajax时它不会!虽然它与opera/safari/chrome一起工作正常!

<form action="client_entry_action.php" method="post" id="client_entry_form" name="client_entry_form">

<fieldset id="client_info_1">

    <label for="c_name">Name:</label> 
    <input type="text" name="c_name" required placeholder="Name" autofocus="autofocus" />

    <label for="c_phone">Phone Number:</label> 
    <input type="tel" name="c_phone" required placeholder="Mobile/Phone Number" />

    <label for="c_email">Email:</label> 
    <input type="email" name="c_email" required placeholder="email@example.com" />

    <label for="c_address">Address:</label> 
    <textarea name="c_address" ></textarea>


</fieldset>

<fieldset id="client_info_2">   

    <label for="c_info">Additional notes:</label> 
    <textarea name="c_info" ></textarea>

    <input type="submit" name="add_client" value="Add Client" />

</fieldset>        

</form>
Run Code Online (Sandbox Code Playgroud)

ajax firefox html5 autofocus

6
推荐指数
2
解决办法
2万
查看次数

自动对焦在Firefox上不起作用,在来自其他页面时不起作用

我正在使用Javascript创建我的页面.这是一个登录页面,我需要在用户名输入文本上使用自动对焦.此操作适用于IE和Chrome,但不适用于Mozilla!这是我用JS添加的HTML:

'<input id="username" class="loginInput" data-bind="value: userName, valueUpdate: \'afterkeydown\'" type="text" name="User" autofocus><!--User Input text end /-->'
Run Code Online (Sandbox Code Playgroud)

当我使用Mozilla加载页面时,此输入以这种方式设置:

<input id="username" class="loginInput" type="text" autofocus="" name="User" data-bind="value: userName, valueUpdate: 'afterkeydown'">
Run Code Online (Sandbox Code Playgroud)

我真的不明白为什么以这种方式设置"autofocus"属性.我甚至尝试使用JQuery添加属性$("#username").attr('autofocus','autofocus'),仅适用于Chrome和IE.

当我从另一个页面进入登录页面并且每个浏览器都出现自动对焦问题时,会出现第二个问题.

你能帮助我吗?

html javascript firefox google-chrome autofocus

4
推荐指数
1
解决办法
7154
查看次数

标签 统计

autofocus ×2

firefox ×2

ajax ×1

google-chrome ×1

html ×1

html5 ×1

javascript ×1