I’ve got a web page with a button that opens another window.
When the button is clicked and the new page is open, I disable the button (because a need only one page is opened clicking the button).
I use window.open() and not windows.showModalDialog() because the user should work on both pages.
When the second page is closed I have to re-enable the button in the first page.
I’ tried with something like this:
var win = window.open("SecondPage.htm");
// disable button
while (!win.closed) {
setTimeout('', 2000);
}
// re-enable button
But using the while loop slows too much the browser, so it’s actually impossible to work on the first page…
Is there a better solution to my problem?
is NOT
sleep()Your while loop keeps turning, and will indeed consume all the CPU, thus slowing down the browser.
Better: