[jQuery] IE7, window.open hangs

[jQuery] IE7, window.open hangs


I am trying to add JQuery functionality to a window created with
window.open, document.write, etc. and as a result IE7 is hanging (99%
cpu). Here is the html creating the window:
<html>
<head> <title>Junk1</title>
<script src="\cgi-bin\jquery-1.2.3.js"></script>
<script language="JavaScript" type="text/JavaScript">
$(document).ready(function() {
alert('Test');
});
function popUp()
{
OpenWindow=window.open("", "newwin", "height=700,
width=400,toolbar=no,resizable=yes,scrollbars="+scroll+",menubar=no");
OpenWindow.document.write('<html>');
OpenWindow.document.write('<head><title>PopUp<\/title>');
OpenWindow.document.write('<script src="\\cgi-bin\\jquery-1.2.3.js"><\/
script>');
OpenWindow.document.write('<script src="\\cgi-bin\\inPopUp.js"><\/
script>');
OpenWindow.document.write('<script type="text\/javascript">');
OpenWindow.document.write('$(document).ready(function() {');
OpenWindow.document.write('alert("in1");');
OpenWindow.document.write('});');
OpenWindow.document.write('$(document).ready(function() {');
OpenWindow.document.write('alert("in2");');
OpenWindow.document.write('});');
OpenWindow.document.write('<\/script>');
OpenWindow.document.write('<\/head>');
OpenWindow.document.write('<body>');
OpenWindow.document.write('<span class="ml_Money">$123,456.78<\/
span>');
OpenWindow.document.write('<\/body><\/html>');
OpenWindow.document.close();
};
</script>
</head>
<body>
<a href="javascript:popUp();">PopUp</a>
</body>
</html>
and here is inPopUp.js:
$(document).ready(function() {
alert("in0");
});
If I remove inPopUp.js then the popup window works fine, and
repeatably. However, with it the new window can be opened and close
only 0 to 4 times (seems random) before IE7 hangs (TaskManager shows
high cpu). I have tested this with Safari v3 and it works fine, no
matter how many times I open and close the window. Any ideas/
suggestions?
Dennis