javascript - 自动点击页面加载
问题描述
下面提到的代码加载了一个带有购买篮子按钮的页面。目前我手动单击按钮运行代码任何人都可以在页面加载后添加自动单击按钮。我在编码方面完全愚蠢。需要一个完全就绪的代码。请帮忙。
<!-- The basket will be linked to this element's onClick //-->
<button id="custom-button" autofocus >Buy the basket</button>
<!-- Include the plugin //-->
<script src="https://kite.trade/publisher.js?v=3"></script>
<script>
// Only run your custom code once KiteConnect has fully initialised.
// Use KiteConnect.ready() to achieve this.
KiteConnect.ready(function() {
// Initialize a new Kite instance.
// You can initialize multiple instances if you need.
var kite = new KiteConnect("tlhzuxkhbqzcvxrw");
// Add a stock to the basket
kite.add({
"exchange": "NSE",
"tradingsymbol": "INFY",
"quantity": 5,
"transaction_type": "BUY",
"order_type": "MARKET"
});
// Register an (optional) callback.
kite.finished(function(status, request_token) {
alert("Finished. Status is " + status);
});
// Render the in-built button inside a given target
kite.renderButton("#default-button");
// OR, link the basket to any existing element you want
kite.link("#custom-button");
});
</script>
解决方案
$(window).load(function (){ $("#custom-button").click(); });
请在页面加载时给出点击事件。
推荐阅读
- ios - Firebase 推送通知适用于 Android,但适用于 ios 仅适用于 Firebase 控制台
- php - 为什么 strtotime("I can") 在 php 中返回日期值?
- r - R ggplot2堆积条形图,y轴百分比,条形计数
- android - android应用程序中的iFrame不允许任何网络请求
- c++ - Arduino的步进电机速度控制
- vb.net - 读取 JSON 文件 vb.net Newtonsoft
- perl - Perl 中的 SOAP 请求
- c - 数组名称是否也在 C 中的内存中占用空间?
- c# - 将数据插入数据库时未提供参数“@id”
- node.js - Node.js 我的 XML 没有读取我的 XSLT