Apurb
Apurb

Reputation: 15

I want the window to be closed after few seconds, using in google scripts by using html

<!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>

Instead of the user clicking on Close button, I want the onclick operation to happen automatically after few seconds. Please help.

Upvotes: 0

Views: 77

Answers (1)

Vasanthi GV
Vasanthi GV

Reputation: 83

Because of security issues closing a window is disabled unless the same script created that window. But if you want to click that button after a specific time use setTimeout() function.

<!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>

Upvotes: 1

Related Questions