Forum Moderators: open
<BODY>
<SCRIPT LANGUAGE="JavaScript" type="text/javascript">
<!--
onLoad=opener.update();
//--></SCRIPT>
</BODY>
The problem is that I have read that browsers will not allow for you to cross-window script in windows which already have HTML content. When I add my toolbar HTML to the popup, this is indeed true for Opera and Konqueror (KHTML, like Safari): they show the toolbars, but have none of the cross-window scripting output. Firefox, on the other hand, does show the cross-window output.
So my questions are:
1) Is it possible to somehow get the other important browsers - Opera, KHTML, and ie to do the cross-window scripting when other HTML content exists, or should I resign myself to having to have this HTML also output via cross-window scripting along with the rest?
2) Can I just use document.writeln to either link the javascript in a separate file, or else to write it out like normal cross-window scripting (properly escaped, of course), or will this fail to produce javascript that works?
...I have read that browsers will not allow for you to cross-window script in windows which already have HTML content
I'm pretty sure this only applies if the content does not originate on the same domain and is a security consideration. I just did this dance with a Real Estate customer who thought he was smart enough to outsmart his external MLS sites.
If it's on your domain you should be able to write to any windows you open if they are correctly referenced from any other window.
As for accessing the code from elsewhere, what you could do is put all your common code in an external .js and reference THAT from your pop-ups.
var windowHandler = '';
var esite = '';
windowHandler = window.open('err.html','window_id_3866','toolbar=no,directories=no,status=no,scrollbars=yes,resizable=yes,menubar=no,height=700,width=600');
if (!windowHandler.opener) windowHandler.opener = self;
function update() {
esite=windowHandler.document.open();
windowHandler.focus();
windowHandler.document.writeln('escaped HTML stuff');
esite=windowHandler.document.close();
}
Another thing I could do, I guess, is use an equivalent of PHP's readfile() if this exists in javascript, and just readfile() my toolbar HTML into the popup before the cross-site scripting content is written to it.
Any thoughts very much welcome; I'm quite the know-nothing when it comes to js.