2017-02-26 56 views
0

我在我的網站的網頁中加載了一個iframe頁面。 現在,我需要在頁面加載後自動點擊按鈕進入iframe。如何在頁面加載後自動點擊iframe中的按鈕?

按鈕的代碼是:

<button type="button" id="submit-button" class="btn trusted-commit-payment">pay now!</button> 

誰能告訴我的代碼,這樣做嗎?

+0

的[點擊頁面加載一個按鈕元素可能的複製](http://stackoverflow.com/questions/21418915/click-a-button-element-on-page-load) – Siraj

回答

0

我希望這會有所幫助。

的Javascript

document.getElementById("myframe").addEventListener('load', function() { 
      document.getElementById("submit-button").click(); 
    }); 

JQuery的

$('iframe').on('load',function(){ 
    $('#submit-button').click(); 
}); 

this

+0

此代碼等待iframe完全加載? – Pacman94

+0

再看看答案,我做了一些改變。 – Siraj

+0

哇,非常感謝,明天我會試試這個代碼,並讓你知道它是否工作。 – Pacman94

相關問題