Solved

Need help to close a browser automatically

Posted on 2012-03-16
6
268 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Several part series to implement Internet Explorer 11 Enterprise Mode
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…
Shows how to create a shortcut to site-search Experts Exchange using Google in the Chrome browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch the Search Engine Menu: In chrome, via you…

920 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now