Home  >  Article  >  Web Front-end  >  Same domain jQuery (cross) iframe operation DOM (explanation with examples)_jquery

Same domain jQuery (cross) iframe operation DOM (explanation with examples)_jquery

WBOY
WBOYOriginal
2016-05-16 17:08:161101browse

Frame is still quite popular at present, and it is used in many places to implement special situations. For example, traditional upload, select under ie6, proxy, cross-domain, etc. Today, I will briefly describe the related operations across iframes, mainly using jQuery to operate the DOM structure.

Copy code The code is as follows:






Copy code The code is 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 the content written by index.php when operating aa.php');
});

The main method is contents(), which reads iframe.

2. iframe cross-parent frame operation iframe

Copy code The code is as follows:

< ;!DOCTYPE html>

bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb