establecer el valor de un formulario en iframe y enviar el formulario.
window.frames['equityIFrame'].document.forms[0].[actionParam] = "equityAction"; window.frames['equityIFrame'].document.forms[0].submit();Este código funciona bien en IE y otros navegadores.
En el navegador Edge, arroja el siguiente error.
no se puede leer la propiedad 'formularios' de undefined.
¿Cuál será el trabajo en torno a esto.
Puede usar HTMLIFrameElement.contentWindow para acceder al documento del iframe y su DOM interno. Puede consultar mi código de muestra a continuación, funciona bien en Edge y otros navegadores:
marco flotante.html:
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title></title> </head> <body> <iframe src="form.html" id="test"></iframe> <input type="button" value="click" onclick="ChangeIframe()" /> <script> function ChangeIframe() { document.getElementById("test").contentWindow.document.getElementById("fname").value = "myname"; document.getElementById("test").contentWindow.document.forms[0].submit(); } </script> </body> </html>formulario.html:
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title></title> </head> <body> <form action="index.html" method="get"> <label for="fname">First name:</label> <input type="text" id="fname" name="fname"><br><br> <label for="lname">Last name:</label> <input type="text" id="lname" name="lname"><br><br> <input type="submit" value="Submit"> </form> </body> </html>