Solved

Need help to close a browser automatically

Posted on 2012-03-16
6
270 Views
Last Modified: 2012-03-22
I have a task scheduler which opens a IE browser with a URL and I want to close it after 15mins within the script but its not working as the browser keeps asking a message for confirmation to close or cancel and I use IE 8.

I tried to use a VB script instead and that also fails due to this IE confirmation message box.

Can anybody help me how can I pass this automatically, any VB or Javascript is appreciated that I can schedule to run which opens a browser with a URL and closes it automatically after 15mins.
0
Comment
Question by:welcome 123
  • 3
  • 2
6 Comments
 
LVL 22

Expert Comment

by:Kim Walker
ID: 37731147
Do you just want to close one of multiple browser windows or do you want to exit the browser application? I don't think you can exit the application without generating the alert.
0
 
LVL 9

Assisted Solution

by:experts1
experts1 earned 500 total points
ID: 37733039
Try mad below:

var x;
function closex(){
x = setTimeout("self.close()",900000); // close after 15 mins
}

Open in new window

0
 
LVL 9

Expert Comment

by:experts1
ID: 37733102
Important note:

For above code to work, you need to launch
the window as a popup window or child window
from a main window.

The main window will always prompt for
confirmation!
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

Author Comment

by:welcome 123
ID: 37734076
I was able to open and close a browser immediately but when I use a URL to open from the below code it does not work as shown below: i.e in the window.open if I use

window.open("http://www.google.com", '_self', ''); it does opne google but doesn't close

<html>
<head runat="server">
    <title></title>

    <script language="javascript" type="text/javascript">
        function CloseWindow() {
            window.open('', '_self', '');
           
             var x;
             x = setTimeout("self.close()",60000); // close after 1 min                  

        }
    </script>

</head>
<body onload="CloseWindow();">
    <form id="form1" runat="server">
    <div>
   
    </div>
    </form>
</body>
</html>
0
 

Accepted Solution

by:
welcome 123 earned 0 total points
ID: 37734117
Well I worked out a solution based on the code you gave and added some logic to close the main window also and here it is:

<html>
<head runat="server">
    <title></title>

    <script language="javascript" type="text/javascript">
        function CloseWindow() {
            mywindow=window.open("http://www.google.com", "test", '');
           
             var x;
             x = setTimeout("alertMsg()",900000); // close after 1 min      
                             

        }

function alertMsg()
{
mywindow.close();
otherwindow=window.open('', '_self', '');
var y;

 y = setTimeout("self.close()",930000); // close after 1 min

}
    </script>

</head>
<body onload="CloseWindow();">
    <form id="form1" runat="server">
    <div>
   
    </div>
    </form>
</body>
</html>
0
 

Author Closing Comment

by:welcome 123
ID: 37751591
Well the reason is the experts said that there is no way to close the main window without confirmation  but I did close the main window also using the javascript and that is why i am giving some credit to myself but i started with the advise of the expert so they do deserve the credit but for users finding an asnwer like me i want to show them my solution and hence accepting my solution so public user who don't pay mobey can see this solution.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I had to do a bit of research to find the answer to this question so I thought I'd share my results.  Due to our outdated mainframe systems, we need to downgrade IE9 to IE8 in order to stay compatible.  We also needed to downgrade Java.  In order to…
I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Google currently has a new report that is in beta and coming soon to Webmaster Tool accounts. This Micro Tutorial will highlight new features for Google Webmaster Tools.

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question