Home > Web Front-end > JS Tutorial > body text

jQuery controls iFrame (example code)_jquery

WBOY
Release: 2016-05-16 17:14:21
Original
1414 people have browsed it

Using jQuery to get the value of an element of the parent window in IFRAME
It can only be achieved by combining the DOM method and jquery method

1. Select all radio buttons in the IFRAME in the parent window
$(window.frames["iframe1"].document).find(" input[@type='radio']").attr("checked","true");

2. Select all radio buttons in the parent window in the IFRAME
$(window.parent.document).find(”input[@type= 'radio']").attr("checked","true");

iframe:

Test passed in IE7

" -//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">









Use jquery to operate iframe



1. There are two ifames in the content





jQuery in leftiframe changes the src code of mainiframe:
$("#mainframe",parent.document.body).attr("src","http://www.jb51.net")


2. If there is an ifame with the ID of mainiframe in the content