You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

请求实现页面加载时自动点击KiteConnect自定义下单按钮及完整代码

Auto-Click "Buy the Basket" Button for KiteConnect

Got it, here's the complete, ready-to-run code that will automatically click the "Buy the basket" button right after the page and KiteConnect plugin finish loading—no manual clicks needed! Since you mentioned you don't know coding, this is a drop-in solution you can use directly:

<!-- 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");
    // Auto-click the button once everything is ready
    document.getElementById("custom-button").click();
});
</script>

Quick breakdown for clarity:

  • The critical line here is document.getElementById("custom-button").click(); — I placed it inside the KiteConnect.ready() function to make sure it only runs after the plugin is fully set up. This avoids any errors that would happen if we tried to click the button before the basket was linked to it.
  • I kept all your original basket configuration (buying 5 shares of INFY at market price) and the alert callback, so all your intended functionality stays exactly as it was.
  • The autofocus attribute on the button is just a small extra, it doesn't affect the auto-click functionality but makes the button stand out visually when the page loads.

内容的提问来源于stack exchange,提问作者Mohan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.08 19:27:56