0

我正在尝试创建一个用户脚本,该脚本将在加载页面时尽快单击以下按钮。

<button class="btn" tabindex="10" disabled="disabled" onclick="ValidateAndSubmit('1')" title="" pay-tab="1">Do now</*button>

请帮忙,因为我很长时间以来一直在尝试,但没有这样做。

我试过这个:

<script type="text/javascript"> 
setTimeout(function()
 { document.getElementById("btn").click(); },1000); 
</script>
4

1 回答 1

0

Try this

(function() {
    window.addEventListener('load', ValidateAndSubmit('1'), false);
})();

(function() {})() defines a scope that is self executed without waiting for any events.

window.addEventListener('load', ValidateAndSubmit('1'), false); subscribes the function ValidateAndSubmit to window load event so that the function is executed on load. This is the same function you are trying to execute by clicking the button.

于 2013-10-06T13:35:07.817 回答