Well this is just a thought but..maybe you could convert the vb api fucntions of "findwindow" and then "closewindow"
to javascript.
I know there is java api but i dont know about the interchangability of the two.