This article is mainly on the same domain jquery (cross) IFRAME Operation Dom is introduced in detail, the need for friends can come to the reference, hope to help everyone else
Frame is still very popular, many places through it to achieve a special situation. For example, traditional upload, select under IE6, Proxy, Cross-domain and so on. Today, a brief description of the operation across the IFRAME, mainly using jquery to manipulate the DOM structure. Code as follows: <iframe src= "a.php" id= "AA" ></iframe> <iframe src= "b.php" id= "BB" ></iframe > <input type= "button" id= "Read-aa" value= "read iframe #aa" > <input type= "button" id= "Write-aa" Value= "Write iframe #aa" > code as follows: $ (' #read-aa '). Click (function () { var v=$ (' #aa '). Contents (). Find (' body '). HTML (); alert (v); }); $ (' #write-aa '). Click (function () { $ (' #aa ') contents (). Find (' div '). Append (' <hr> This is index.php operation aa.php write content '); }); The Main method is contents (), read the IFRAME. 2, iframe across the parent frame operation IFRAME code is as follows: <! DOCTYPE html> <meta charset= "Utf-8" > <title>bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb< /title> <script src= "Public/jquery.js" ></script> <script> $ (function () { $ (' #read-parent-aa '). Click (function () { var v=$ (' Body ', parent.document. Find (' #aa '). Contents (). Find (' body '). HTML (); alert (v); }); $ (' #write-parent-aa '). Click (function () { &N Bsp $ (' body ', parent.document). "Find (' #aa ')." Contents (). Find (' div '). Append (' <hr> This is the bb.php operation aa.php write content '); }); }); </script> <div> This is the IFRAME #bb里的内容 </div>& nbsp <input type= "button" id= "Read-parent-aa" value= "Cross parent read iframe #aa" > <input type= "button" id= " Write-parent-aa "Value=" cross-parent write iframe #aa "> HTML: Code code as follows: <! DOCTYPE html> <meta charset= "Utf-8" > <title>jquery operation iframe</title> <script src= "http:// Ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js "></script> <iframe src=" a.php "id=" AA "> </iframe> <iframe src= "b.php" id= "BB" ></iframe> <input type= "button" id= "Read-aa" value= "read iframe #aa" > <input type= "button" id= "Write-aa" value= "write iframe #aa" > <script> $ (function () { $ (' #read-aa ') . Click (function () { var v=$ (' #aa '). Contents (). Find (' body '). html (); alert (v); }); $ (' #write-aa '). Click (function () { $ (' #aa '). Contents (). Find (' div '). Append (' <hr> This is the index.php operation aa.php write content '); }); }); </script>