Summary of jQuery Operating js Function in iframe

  • 2021-07-02 23:04:09
  • OfStack

In this paper, an example is given to describe the method of jQuery operating js function in iframe. Share it for your reference, as follows:

1. jquery manipulates elements in iframe (2 ways)


var tha = $(window.frames["core_content"].document).find("#trewuuu").html();
var thb = $("#core_content").contents().find("#trewuuu").html();

2. Operate the elements in the parent interface (header: id for an element)


$('#header', parent.document).text()

3. js calls js function in iframe (2 kinds)


window.frames["core_content"].window.testIframe2("11");
document.getElementById("core_content").contentWindow.testIframe2("11");

4. jquery calls the js function of iframe (there will be a return value with parameters)


$("#core_content")[0].contentWindow.testIframe2("11");

Precautions:

To be in the same domain name as the included iframe (because it cannot be cross-domain)

For more readers interested in jQuery related content, please check the topics of this site: "Summary of iframe Operation Skills", "Summary of jQuery Extension Skills", "Summary of jQuery Common Plug-ins and Usage", "Summary of jQuery Drag Effects and Skills", "Summary of jQuery Table (table) Operation Skills", "Summary of Ajax Usage in jquery", "Summary of jQuery Common Classic Special Effects", "Summary of jQuery Animation and Special Effects Usage" and "Summary of jquery Selector Usage"

I hope this article is helpful to everyone's jQuery programming.


Related articles: