PDA

View Full Version : popupwindow opens correctly once, but not twice


ruudvansoest
11-12-2002, 09:14 PM
I have written a popup function that receives values for page, name and dimensions from the calling page and then opens a new window. This is it:

function newWindow(page, name, dimensions) {
newWindow = window.open(page, name, dimensions);
}

This function is called via a link on the calling page. This is it:

<a href="javascript:newWindow('isola-luchtfoto-in-venster.htm', 'nieuw', 'width=666,height=427')"><img src="images/pijltje.gif" width="14" height="14" align="absmiddle" border="0"></a>vergroting

This works fine: I click the link and the popup window opens fine. After that, I close the new popup window via the x-icon on the right top of the window - everything still fine, no problem at all.

But then!!! If I click the calling link again the popup window refuses to open. In stead, there appears a message on the status line: error in page. !!!

When I refresh the browser window (F5) everything works fine again. Strange.

Question: what is happening and how do I get the function to work correctly?

Thanks,
Ruud

chrismiceli
11-12-2002, 10:17 PM
what is the error ie is giving you, i see nothing wrong with the syntax here, there must be more code that is causing the problem.

PauletteB
11-12-2002, 10:18 PM
Your way: (you need to change the function newWindow)

<body>
<script>
function nWin(page, name, dimensions) {
newWindow = window.open(page, name, dimensions);
}
</script>
<a href="javascript:nWin('isola-luchtfoto-in-venster.htm', 'nieuw', 'width=666,height=427')"><img src="images/pijltje.gif" width="14" height="14" align="absmiddle" border="0"></a>
</body>

Or another way:

<body>
<a href="isola-luchtfoto-in-venster.htm" target="nieuw"
onClick="window.open('','nieuw','width=666,height=427')"><img src="images/pijltje.gif" width="14" height="14" align="absmiddle" border="0"></a>
</body>

ruudvansoest
11-12-2002, 11:35 PM
Hi Chris, hi Paulette,

Thanks for your answers. The problem is solved, great!

Still, I'm wondering what the problem exactly was. Function name and variable name must be different, I understand. But why not on the first call?

I forgot to mention that the function is read from a .js-library. I read in a tutorial that library code, once read, will be read the next time from the cache (speed!).

So, might the problem be something like this: on the first call the variable newWindow doesn't yet exists (it only comes to live in the function body). Then, on the second call, the variable still lives in the cache, as does the fucntion with the same name. And then function name and variable name would conflict?

Thanks again,
Ruud