Click here to Skip to main content
15,886,664 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I am Write javascript for windows automaticaly code but script not supported chrome.Please help me to solve this problem

JavaScript
function SetupWindowClose()
{
window.setTimeout("window.close()",1000);
}
Posted

In case of chrome , you can only close the window if it is opened by script.
You can try this.
JavaScript
window.open('', '_self', ''); 
window.close();
 
Share this answer
 
Comments
Manfred Rudolf Bihy 3-May-13 7:18am    
Looks like you found it before me! :)
Have a 5!
Shubhashish_Mandal 3-May-13 7:26am    
Thanks :)
Here is a sample that will work in google chrome:

HTML
<html>
    <body>
        <script type="text/javascript">
            window.open('', '_self', ''); 
            function SetupWindowClose()
            {
                //alert("Set it!");
                window.setTimeout("window.close()", 3000);
            }
            //alert("Before execute!");
            SetupWindowClose();
        </script>
        <h1>Hello goodbye!</h1>
    </body>
</html>


Regards,

— Manfred
 
Share this answer
 
You can try this:-

C#
function SetupWindowClose()
{
      window.open('javascript:window.open("", "_self",  "");window.close();', '_self');
}


OR

C#
function SetupWindowClose()
{
    close();
}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900