Forum Moderators: travelin cat
It's a little unclear what you want to accomplish. Including your code is big help (thanks) but also telling us what action you are trying to achieve is very useful.
It looks as if you are trying to reload and then close a window?
From your code, as posted, there are a few punctuation problems which will foul up a browser's JavaScript interpreter/compiler.
After your </script> tag, there appears to be a single quote ( ' ) character and then a semicolon.
Semicolons need to be placed at the end of each JS line of code, but NOT after the HTML closing tag </script>.
The <...> tags are HTML code. The other stuff is JS. You do need (and have properly) semicolons after your script steps, so that's not a problem.
Remove the extra characters ( the ' and the ; ) for sure.
Now, the other issue.
If you are trying to refresh the page (reload it), then you can use something like:
document.location.href = document.location.href
or just document.location
(These depend on the browser somewhat, but you should already be filtering for that as needed so I won't elaborate here. You said you were testing with IE 5.1.6 so maybe that's what's most important. That's also what I use and code for.)
echo '<script language="JavaScript">
<!--
window.opener.location.reload(true);
window.close();
//-->
</script>';
I re-mention hereunder my problem :
I have 2 pages A and B. The page B is opened when click on a link on page A. Now, at the page B, I want to reload the page A and close the page B. So I used the script as above. The problem is that they tell me my script didn't work with IE 5.1.6/Mac (and I don't have Mac for test). I did what you had advised :
window.opener.location.href = window.opener.location.href;
but they continue telling me that it didn't work. If possible, could you please do some test on your computer with Mac or give me another solution?
Thanks so much in advance!
Yes, letuan - this causes your problem. This tag doesn't open a external window (in Javascript sense) - it just opens a new browser instance. If you want to access a window through js, you need to create a window object first. All command like window / opener don't work if the "window" wasn't opened through a js command.
Try this intstead:
<a href="javascript:window.open('http://yoururldotcom.com')">open new window</a>
After this you can access the window through the opener command (see my last post).
There are several optional parameter that can be used with window.open like show toolbar, show location, window size (with, height) and many more. Try searching google for Javascript Window Open [google.com] ...