【问题标题】:Programmatically go to a site and click a button using Javascript?以编程方式访问网站并使用 Javascript 单击按钮?
【发布时间】:2017-03-31 02:10:31
【问题描述】:

我想创建一个链接,这个链接会自动引用 google.com 并点击他们的 HTML 按钮

Google 搜索按钮代码:

<input value="Google Search" aria-label="Google Search" name="btnK" type="submit" jsaction="sf.chk">

如何在使用 javascript 的链接中做到这一点?

【问题讨论】:

  • 你想做的事情是不可能的。

标签: javascript html


【解决方案1】:

这是 JQuery 中的一些内容,来自here

<script type="text/javascript">
    $(document).ready(function() { 
        $(function() { 
            $("button[aria-label='Google Search']").click(); 
        });
    });
</script>

【讨论】:

  • 如果可能的话,我希望它包含在链接中。就像您可以执行诸如 javascript: //code 之类的操作一样。在 URL 搜索栏中。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-05-11
  • 2021-09-30
  • 1970-01-01
  • 2016-10-31
  • 1970-01-01
相关资源
最近更新 更多