Search code examples
inputradio-buttonmicrosoft-edgeappendchild

I add an radio button to the opener Window with appendChild. But in MS Edge it doesnt work


I add a Radio button with the function appendChild to the opener window. That works fine in Firefox and Chrome, but not in Microsoft Edge.

From the first HTML page I call with form Action a new targed window. Inside this window I placed a Javascript that insert with appendChild a new Radio Button on the first opener Window. The Code works fine in Firefox and Chrom. In MS Edge it has an error with the appendChild command.

Part of HTML Code from the first Window

//Position of Radio button
</td><td id="logos">
<input type="radio" name="logo_radio" value="test5.jpg" checked>test5.jpg<br>
<input type="radio" name="logo_radio" value="malvorlagenfeuerwehr04.jpg">malvorlagenfeuerwehr04.jpg<br>
</td></tr>
//Calling now window with a button:
<input name="logo_test" type="button" onclick="document.formLogo.submit();" Value="Neues Logo laden">
<form name="formLogo" enctype="multipart/form-data" action="add_logo.php" method="post" accept-charset="ISO-8859-1" target="_blank">
<input type="hidden" name="id" value="{$_POST['id']}">
<input type="hidden" name="eintrag" value="$eintrag">
</form>

Javascript function in the second Window:

<script type="text/javascript">
try {
  var newRadioButton = document.createElement("input");
  newRadioButton.setAttribute('type','radio');
  newRadioButton.setAttribute('name','logo_radio');
  newRadioButton.setAttribute('value','$file_new');
  var obj1 = window.opener.document.getElementById("logos");
  obj1.appendChild(newRadioButton);
}catch(err) {alert(err.message);}
</script>

IE returns a error message "SCRIPT 65535: invalid argument"

Manny thanks for your help.


Solution

  • I found the solution. The new Radio element have to create into the opener window:

    var newRadioButton = window.opener.document.createElement("input");