?
Solved

Need help to close a browser automatically

Posted on 2012-03-16
6
Medium Priority
?
283 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
Containers & Docker to Create a Powerful Team

Containers are an incredibly powerful technology that can provide you and/or your engineering team with huge productivity gains. Using containers, you can deploy, back up, replicate, and move apps and their dependencies quickly and easily.

 

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

PowerShell Core for Advanced Linux Administrators

Understand advanced principals around Powershell Core with a focus on the Linux Administrator.  This course covers how to administer numerous environments across multiple platforms including Linux, Azure, AWS, and Google Cloud from a single shell instance.

Question has a verified solution.

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

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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)
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…
Suggested Courses

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