Forum Discussion

techgirlbb's avatar
techgirlbb
Contributor
8 years ago

Closing browser windows if Open

Hi I am trying to write a function in JavaScript to close the browser if open else display message: function ClosingApplications2() { var p ; p=Sys.Browser("iexplore"); if (p.Exists){ p.Close()...
  • tristaanogre's avatar
    tristaanogre
    8 years ago

    I actually go a little lower level to go beyond just browser to actually checking the process.  This is code I cobbled together from several sources.  This works for IE.  I'm assuming it could be adapted to work for any browser process.

                var counter = 0;
                var browser = Sys.WaitProcess('iexplore', 1000);
                while((browser.Exists)){
                    browser.Terminate();
                    browser = Sys.WaitProcess('iexplore', 1000);
                }