PDA

View Full Version : close window with js



BCRandCo
10-25-2015, 06:36 PM
Sorry, been out of the loop on js for a while and need to fix a page. Could someone help me out? From one page(Win1), I open a second with js (win2), which presents results of data collected on that page (win2) on win 3, also opened and written from win2 with js. I would like win2 closed when win 3 is opened. Is that possible, dependably.
thx.

Beverleyh
10-25-2015, 07:29 PM
Hmmm, you've forgotten to include your code but if you haven't got that far, maybe start your research here https://www.google.co.uk/search?q=close+a+window+javascript

And if you need more help, please provide a reduced case setup to demonstrate the behaviour. Also include the code you've written to close the window so that we can make suggestions on fixing the parts that dont work as expected.

styxlawyer
10-25-2015, 08:06 PM
A very simple and effective solution is to just clear the contents of the current window and then rewrite them. This line is very useful:



document.getElementsByTagName('body')[0].innerHTML="";


Use with caution as it will clear everything (including scripts) that is contained between the <body> and </body> tags!

BCRandCo
10-26-2015, 01:48 AM
Thanks. That will work well.