How hard can it be to reload the main window ?!?!!?

S

sentinel

Hi all,

I'm trying to reload a frame from a pop-up, but really cannot figure
this out.

Within my index.htm file, I make a link to call a pop-up frame with a
javascript function that calls the following code from an external
javascript source file, dynamically created with PHP

document.write('<a href="javascript:void(0);"
onclick=\'win1=window.open("http://127.0.0.1/comments.php?site_name=<?php
echo $site_name;?>&linker='+linker[argument]+'", "devWindow",
"height=450,width=420,screenX=0,left=50,screenY=0,top=100,location=0,menubar=0,scrollbars=1,status=0,toolbar=0",
"option2") ;win1.focus(); \' target="">'+href+'</a>');



Within the pop-up window, I use the following code


----> Head section

<script type="text/javascript">
cleanup () {
opener.location = opener.location.href;
opener.location.reload();
}
</script>
</head>

<body class="body" marginheight="0" marginwidth="0"
onUnload="cleanup()">



I want the file index.php to reload when the pop-up is closed down. I
seem to have tried every variation of opener.reload(), but still can't
manage it solve it.

Can anyone see what I am doing wrong ?

I'm starting to pull my hair out.....


Rgds
Neil.
 
M

Michael Winter

Within my index.htm file, I make a link to call a pop-up frame with a
javascript function that calls the following code from an external
javascript source file, dynamically created with PHP

document.write('<a href="javascript:void(0);"
onclick=\'win1=window.open("http://127.0.0.1/comments.php?site_name=<?php
echo $site_name;?>&linker='+linker[argument]+'", "devWindow",
"height=450,width=420,screenX=0,left=50,screenY=0,top=100,location=0,menubar=0,scrollbars=1,status=0,toolbar=0",
"option2") ;win1.focus(); \' target="">'+href+'</a>');

I'm not going to check too hard if that's syntactically correct. You
should only post client-side code, replacing server-side code with what
might be generated. Formatting your posts with indentation and controlled
line-breaks (rather than newsreader wrapping) would also be helpful.
However, I will say this:

Don't use the JavaScript pseudo-protocol (href="javascript:...") unless
there is a good reason to. In this case, it isn't much of a problem as
non-JavaScript users won't even see that link, but for other cases, one
should consider alternative approaches, such as,

- Buttons
- <a href="" onclick="<code>;return false;"
- <a href="page.html" target="someWindow"
onclick="window.open('page.html','someWindow');return false"
<script type="text/javascript">
cleanup () {

Syntax error. Should be:

function cleanup() {
opener.location = opener.location.href;
opener.location.reload();
}
</script>
</head>

<body class="body" marginheight="0" marginwidth="0"
onUnload="cleanup()">

I want the file index.php to reload when the pop-up is closed down. I
seem to have tried every variation of opener.reload(), but still can't
manage it solve it.

Other than that syntax error, the problem could be that the onunload event
isn't firing. Onunload is unreliable, at best. I know for a fact that
Opera only fires it when the page is changed. Closing the tab, window, or
refreshing the page does nothing. Mozilla fires it when the page is
changed or refreshed, but not when closed. Netscape and IE fire it when
the page is changed, refreshed or closed. That's only four browsers, all
of which displaying different behaviours, amongst a hundred.

If this refreshing is critical, it might be worth integrating the pop-up
window into the main page, then using a link to go to another page.

Mike
 
T

Thomas 'PointedEars' Lahn

KD said:
This worked for me:

function cleanup()
{
// This is done in the following way because Mozilla does not
// want to obey the simpler .reload() function.
// window.opener.location.reload(); -- Mozilla Bug

There is AFAIS no Mozilla bug (any more).
var originalLocation = window.opener.location;
window.opener.location.href = originalLocation;

No need for the variable.
window.close();
}



[Top post]

Please do not do that.


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top