Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/417.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/242.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 按代码按TAB键_Javascript_Php_Jquery_Tabs - Fatal编程技术网

Javascript 按代码按TAB键

Javascript 按代码按TAB键,javascript,php,jquery,tabs,Javascript,Php,Jquery,Tabs,我试着用代码来按TAB键;如何在1秒自动按下(tab)后完成代码 \t是制表符,但它不会发送制表键以移动到下一个对象 我认为您需要一个自动化工具,如?一个可行的解决方案 以下是来自给定链接的示例: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta h

我试着用代码来按TAB键;如何在1秒自动按下(tab)后完成代码


\t
是制表符,但它不会发送制表键以移动到下一个对象


我认为您需要一个自动化工具,如?

一个可行的解决方案

以下是来自给定链接的示例:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

    <script type="text/javascript">
      /*************************************************
       * Example showing how to simulate pressing a key.
       *************************************************/

      function pressChar(char)
      {
        try
        {
          // Create the key press event.
          var pressEvent = document.createEvent('KeyboardEvent');
          pressEvent.initKeyEvent("keypress", true, true, window, 
                                    false, false, false, false, 
                                    0, char.charCodeAt(0));

          var input = document.getElementById('input_field'); // Get the element where you want to press.

          input.dispatchEvent(pressEvent); // Press the key.
        }
        catch (e) {
            alert ("Your browser does not support this example!");
        }
      }
    </script>


    <title>Simulate pressing a key</title>
  </head>

  <body>
    <button onclick="pressChar('s')">Simulate pressing the 's' key in the input field.</button>
    <input type="text" id="input_field" />
  </body>

</html>

/*************************************************
*演示如何模拟按键的示例。
*************************************************/
函数pressChar(char)
{
尝试
{
//创建按键事件。
var pressEvent=document.createEvent('KeyboardEvent');
pressEvent.initKeyEvent(“按键”,真,真,窗口,
假,假,假,假,
0,char.charCodeAt(0));
var input=document.getElementById('input_field');//获取要按的元素。
input.dispatchEvent(pressEvent);//按键。
}
捕获(e){
警报(“您的浏览器不支持此示例!”);
}
}
模拟按键
模拟按下输入字段中的“s”键。

如果回答您的问题,请将此答案标记为已接受。

此行动的预期目标是什么?下一个链接?元素是否有
选项卡索引
?你能显示你的标记吗?请不要只提供链接答案,你可以从链接中复制内容,然后指定你获取内容的来源。好的:谢谢你的建议:我已经编辑了我的文章,以包含相关代码
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

    <script type="text/javascript">
      /*************************************************
       * Example showing how to simulate pressing a key.
       *************************************************/

      function pressChar(char)
      {
        try
        {
          // Create the key press event.
          var pressEvent = document.createEvent('KeyboardEvent');
          pressEvent.initKeyEvent("keypress", true, true, window, 
                                    false, false, false, false, 
                                    0, char.charCodeAt(0));

          var input = document.getElementById('input_field'); // Get the element where you want to press.

          input.dispatchEvent(pressEvent); // Press the key.
        }
        catch (e) {
            alert ("Your browser does not support this example!");
        }
      }
    </script>


    <title>Simulate pressing a key</title>
  </head>

  <body>
    <button onclick="pressChar('s')">Simulate pressing the 's' key in the input field.</button>
    <input type="text" id="input_field" />
  </body>

</html>