views:

132

answers:

1

My goal is to submit a form in a new window. I'm using the following code:

var xmlWindow = window.open("getXML.htm");
xmlWindow.document.getElementById("getXML").action = "getData.asp";
xmlWindow.document.getElementById("getXML").method = "post";
xmlWindow.document.getElementById("getXML").innerHTML = "<input type='hidden' name='moduleID' value='ex1'/>";
xmlWindow.document.getElementById("getXML").submit();

This works fine in IE and Firefox, but in chrome the xmlWindow.document.getElementById("getXML") is null. Any suggestions?

for reference here is getXML.htm:

<html>
<head>
    <title>getXML</title>
</head>
<body>
<form id="getXML" name="getXML">
</form>
</body>
</html>
+1  A: 

You will want to wait for the page to have finished loading (technically you would need this in any browser) -- eg. wait for the onload event to fire before trying to access the document.

olliej