我在我的網站的網頁中加載了一個iframe頁面。 現在,我需要在頁面加載後自動點擊按鈕進入iframe。如何在頁面加載後自動點擊iframe中的按鈕?
按鈕的代碼是:
<button type="button" id="submit-button" class="btn trusted-commit-payment">pay now!</button>
誰能告訴我的代碼,這樣做嗎?
我在我的網站的網頁中加載了一個iframe頁面。 現在,我需要在頁面加載後自動點擊按鈕進入iframe。如何在頁面加載後自動點擊iframe中的按鈕?
按鈕的代碼是:
<button type="button" id="submit-button" class="btn trusted-commit-payment">pay now!</button>
誰能告訴我的代碼,這樣做嗎?
我希望這會有所幫助。
的Javascript
document.getElementById("myframe").addEventListener('load', function() {
document.getElementById("submit-button").click();
});
JQuery的
$('iframe').on('load',function(){
$('#submit-button').click();
});
讀this
的[點擊頁面加載一個按鈕元素可能的複製](http://stackoverflow.com/questions/21418915/click-a-button-element-on-page-load) – Siraj