Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Need help to close a browser automatically

Posted on 2012-03-16
6
Medium Priority
?
287 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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
Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

 

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article offers some helpful and general tips for safe browsing and online shopping. It offers simple and manageable procedures that help to ensure the safety of one's personal information and the security of any devices.
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
This Micro Tutorial will demonstrate how to add subdomains to your content reports. This can be very importing in having a site with multiple subdomains.
This Micro Tutorial will demonstrate how nuggets on the Web are formatted by using Chrome Developer Tools. These tools would not only view the site's CSS but it can also modify it and save the CSS to use on your own site.
Suggested Courses

618 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