When testing, note that there are html files in the code in the current directory. Copy code The code is as follows: .org/1999/xhtml"> < title>Windows window opens <br>var winID = null; <br>//Open window<br>function openWindow() <br>{ <br>winID = window.open("windowTime.html","JavaScript"); <br>} <br>//Close the window <br>function closeWindow() <br>{ <br>if(winID && winID. open && !winID.closed) <br>{ <br>winID.close(); <br>} <br>} <br>//Change URL <br>function changeURL(newURL) <br>{ <br>if(winID && winID.open && !winID.closed) <br>winID.location.href = newURL; <br>} <br> < body onunload="closeWindow()"> Opening and closing the window