<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
Please wait for few seconds, until this `Dialogue Box` closes. This waiting time is required for the Page to Load Completely. Thank you.<input type="button" value="Close" onclick="google.script.host.close()" />
</body>
</html>
代替用户点击Close button
,
我希望onclick
操作在几秒钟后自动发生。请帮忙。
答案 0 :(得分:1)
由于安全问题,关闭窗口的操作被禁用,除非使用相同的脚本创建了该窗口。但是,如果要在特定时间后单击该按钮,请使用setTimeout()函数。
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
Please wait for few seconds, until this `Dialogue Box` closes. This waiting time is required for the Page to Load Completely. Thank you.
<input type="button" value="Close" id="myButtonId" onclick="myfunction()" /><br>
<script type="text/javascript">
setTimeout(function () {document.getElementById("myButtonId").click();}, 3000);
function myfunction(){
alert("clicked");
}
</script>
</body>
</html>