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

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

WBOY
Release: 2016-05-16 17:08:16
Original
1113 people have browsed it

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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template