我正在尝试自动点击按钮以在加载html页面时启动功能.我已经尝试过document.getElementById('watchButton').click它似乎不起作用,按钮没有被点击.有什么建议?
<div class="content">
<div class="action-area ch30">
<button class="button dh" id="watchButton">Start Geolocation Watch</button>
<button class="button dh" id="refreshButton" >Refresh Geolocation</button>
</div>
Run Code Online (Sandbox Code Playgroud)
javascript:
run:function() {
var that = this;
document.getElementById("watchButton").addEventListener("click", function() {
that._handleWatch.apply(that, arguments);
}, false);
document.getElementById("refreshButton").addEventListener("click", function() {
that._handleRefresh.apply(that, arguments);
}, false);
},
Run Code Online (Sandbox Code Playgroud)
谢谢!