This article describes the method of implementing the iframe framework to obtain values in JS. Share it for your reference, as follows:
Why are there so many different browsers in the world? Every time I encounter a browser compatibility problem with js/css, I always make such an sigh. I really hope that all these browser companies will fall down and only one will be left (obviously this is an impossible good wish). Let’s get back to the point and read the code:
Iframe inner page:
<html> <head> <title>Inside the frame page</title> </head> <body> <div> <input name="txt1" type="text" value="test" /> </div> </body> </html>
Parent class:
<iframe name="frame1" src="" frameborder="1" height="30"></iframe> <p> iframe1Value of Chinese text box:</p> <p> <input type="button" name="Submit" value="getValue" onclick="getValue()" /> </p> <script type="text/javascript"> function getValue(){ var ofrm1 = ("frame1").document; if (ofrm1==undefined) { ofrm1 = ("frame1").; var ff = ("txt1").value; alert("firefox/chrome value result is:" + ff); } else { var ie = ["frame1"].("txt1").value; alert("I value result is:" + ie); } } </script>
I hope this article will be helpful to everyone's JavaScript programming.