I have a main window and a menu window.
The menu window is opened from the main window by clicking on "Open Menu".
A google window can also be opened from the main window by clicking "Open Google". If "google_win" is clicked on in the menu window the google window is focused on.
Now if "Add Google to Menu" is clicked in the main window, another line is written to the menu window also saying "google_win".
This second "google_win" is added by using appendChild and has the same .....focus() code behind it as the first "google_win". But if this second one is clicked the google window is NOT focused on when IE is used. I've tried IE6 and 7 on XP and IE5.2 on OSX. This does work in Firefox and Safari.
This is the main window code:
[HTML]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Untitled</title>
</head>
<script type="text/javascript">
<!--
function opengoogle(){
address="http://www.google.com/"
google_win=window.open(address,'google_win')
}
function addtomenu(win_name){
sectRef = menuwin.document.getElementById('menu_list');
newLine = menuwin.document.createElement("br");
sectRef.appendChild(newLine);
newSpan = menuwin.document.createElement("span");
openscript = "window.opener." + win_name +".focus();"
newSpan.setAttribute('onClick',openscript);
newText = menuwin.document.createTextNode(win_name);
newSpan.appendChild(newText);
sectRef.appendChild(newSpan);
}
function openmenu(){
menuwin=window.open('menutest1.html','Menu','width =200,height=600,resizable=yes,scrollbars=auto,tool bar=yes,location=no,directories=no,status=yes,menu bar=yes,copyhistory=no,left=0,top=100,screenX=0,sc reenY=100');
}
//-->
</script>
<body>
<span onClick="openmenu()">Open Menu</span><br>
<span onClick="opengoogle()">Open Google</span><br>
<span onClick="addtomenu('google_win')">Add Google to Menu</span>
</body>
</html>[/HTML]
This code is for the menu window and belongs in a file called "menutest1.html"
[HTML]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Menu</title>
</head>
<body>
<div id='menu_list'>
<span onClick='window.opener.google_win.focus();'>google _win</span>
</div>
</body>
</html>[/HTML]
These pages are at:
http://insitefo.com/domtest1.html
Any ideas how to get the added "google_win" line to work properly or why it's not working?
Thanks