I'm trying to write to a child window launched with window.open but even when using the onLoad event on the child it appears that the event is firing before the dom is fully loaded.
calling page:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Test me</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="javascript" src="/js/popwindow.js" type="text/javascript"></script>
</head>
<body>
<a href='javascript: popevent("event title","event description",300,300)'>Email me</a></body>
</html>
popwindow.js
function firit(et,ed)
{
popwin.document.getElementById('e_title').innerHTML = et+ " "+ed;
}
function popevent(eventtitle,eventdesc,wid,hei)
{
popwin = window.open('/tools/blank.htm','eventwin','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbar=no,resizable=no,copyhistory=yes,width=400,height=400,left=200, top=150,screenX=200,screenY=150');
popwin.onLoad=firit(eventtitle,eventdesc);
}
blank.htm
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Event Viewer</title>
</head>
<body>
<div class="popupEventTitle s29" id="e_title"></div>
</body>
</html>
When I click the link on the calling page the child page opens but instead of getting "event title event description" written into it I get an error (popwin.document.getElementById('e_title') is null or not an object)
BUT if I place an alert in the firit function as teh first line it seems to buy the child page enough time to load such that the information IS written into the e_title div.
It seems like popwin.onLoad is firing prior to the child page being loaded...
by: Vinod_nkPosted on 2006-01-30 at 21:36:54ID: 15830936
Hi,
I believe that the error is because of path reference problem. I had put all the 3 files in the same folder and got it working. Are you testing from your local machine, without webserver? In that case it should be 'tools/blank.htm' and js/popwindow.js i.e without the "/" in the begining.
Rgds
V