Connecting Tech Pros Worldwide Forums | Help | Site Map

Is-it possible to write in a mother window from a child window ?

orion30
Guest
 
Posts: n/a
#1: Jul 23 '05
Is-it possible to write in a mother window from a child window ?
Like this:
Parent.document.write(............................ ................)



Grant Wagner
Guest
 
Posts: n/a
#2: Jul 23 '05

re: Is-it possible to write in a mother window from a child window ?


"orion30" <orion30@ifrance.com> wrote in message
news:426bc0bb$0$18774$8fcfb975@news.wanadoo.fr...[color=blue]
> Is-it possible to write in a mother window from a child window ?
> Like this:
> Parent.document.write(............................ ................)[/color]

Why not try it and report back to us whether it worked or not?

<script type="text/javascript">
window.newWindowHtml = [
'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">',
'<html>',
'<head>',
'<title>Test Window</title>',
'</head>',
'<body onload="opener.document.write(\'hi there\');">',
'</body>',
'</html>'
].join('\n');
window.open('javascript:opener.newWindowHtml');
</script>

Apparently it does work.

--
Grant Wagner <gwagner@agricoreunited.com>
comp.lang.javascript FAQ - http://jibbering.com/faq


Thomas 'PointedEars' Lahn
Guest
 
Posts: n/a
#3: Jul 23 '05

re: Is-it possible to write in a mother window from a child window ?


Grant Wagner wrote:
[color=blue]
> <script type="text/javascript">
> window.newWindowHtml = [
> '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">',
> '<html>',
> '<head>',
> '<title>Test Window</title>',
> '</head>',
> '<body onload="opener.document.write(\'hi there\');">',
> '</body>',
> '</html>'
> ].join('\n');
> window.open('javascript:opener.newWindowHtml');
> </script>
>
> Apparently it does work.[/color]

However it should not :) You forgot to escape the ETAGO delimiters, hence
it is not Valid HTML. And one also should specify the system identifier
in a DOCTYPE declaration rather than either assuming the UA will use a
reference file or force it into Quirks/Compatibility Mode. It would be
also useful to specify the default scripting language for event handler
attributes no matter if some UAs tested with do not care about that.


PointedEars
Closed Thread