Solved

Need help to close a browser automatically

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

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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

#Citrix #Internet Explorer #Enterprise Mode #IE 11 #IE 8
Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
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.

708 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

11 Experts available now in Live!

Get 1:1 Help Now