I have written this code for close all child window with parent window but after refreshing the parent window child window are not closing. Code bellow.
Code:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html lang="en"> <head> <title>window manager</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <script type="text/javascript"> var windows = []; function conf() { var rand_no_c = Math.random(); var con = rand_no_c.toString(); var_win = 'child'+con.substring(2); windows[var_win] = window.open('test2.html',var_win,'width=400,height=200,left=50,top=20,status=0'); } function closewindow() { for(w in windows) { if(!windows[w].closed) { windows[w].close(); } } } </script> <style type="text/css"> * {margin:0;padding:0;} </style> </head> <body> <div> <a href="javascript:" onclick="conf();">open child window</a>|| <a href="javascript:" onclick="conf();">open child window</a>|| <a href="javascript:" onclick="conf();">open child window</a>|| <a href="javascript:" onclick="conf();">open child window</a>|| <a href="test2.html">Click</a> <button type="button" onclick="closewindow();">close all windows</button> </div> </body> </html>



Reply With Quote

Bookmarks