PDA

View Full Version : closing a pop up


madHatter
12-12-2002, 03:44 AM
Hi

This script seems to work when I want to go back to my home page (from a pop-up window):

<script language="JavaScript">
function open_main(page) {
window_handle = window.open(page,'main');
return false;
}
</script>

<a href="index.html" onClick="return open_main('index.html')">home</a>

but it leaves the pop-up window still open. How can I close it automatically when the normal size (home) page window opens?

Any suggestions, please?

madHatter

PauletteB
12-12-2002, 05:27 AM
Can't you simply close the window (since the index is already opened - no need to reload it) ?

<a href="javascript:window.close()">home</a>

madHatter
12-12-2002, 02:08 PM
Hello PauletteB

Many thanks for your reply.

Actually, the "index.html" page is NOT already open. It is only when the visitor clicks on:

<a href="index.html" onClick="return open_main('index.html')">home</a>

that it opens the main home page ("index.html").

But I do need something like your:

<a href="javascript:window.close()">home</a>

to close the pop up. But I really only want the one text link on the pop up to do BOTH, that is go to the home page AND close the pop up at the same time. So I was looking for something like a combination of what I have and what you have - but don't know how to put it together.

Cheers!

madHatter

requestcode
12-12-2002, 03:50 PM
Right after this line: window_handle = window.open(page,'main');

try this: window.close();

madHatter
12-12-2002, 08:18 PM
Hello RequestCode

<script language="JavaScript">
function open_main(page) {
window_handle = window.open(page,'main');
window.close();
return false;
}
</script>

<body>

<a href="index.html" onClick="return open_main('index.html')">home</a>

</body>

works!

Many thanks again for your help.

Best wishes

madHatter