jQuery Simple Implementation of iframe Highly Adaptive Method Based on Page Content

  • 2021-07-06 09:56:31
  • OfStack

This article describes the simple implementation of jQuery iframe according to the content of the page self-adaptation method. Share it for your reference, as follows:

Mode 1:


// Note: The following code is placed in and iframe Same as 1 Called in pages 
$("#iframeId").load(function () {
    var mainheight = $(this).contents().find("body").height() + 30;
    $(this).height(mainheight);
});

Mode 2:


// Note: The following code is placed in the iframe Called in the child page referenced by the 
$(window.parent.document).find("#iframeId").load(function () {
    var main = $(window.parent.document).find("#iframeId");
    var thisheight = $(document).height() + 30;
    main.height(thisheight);
});

For more readers interested in jQuery related content, please check the topics of this site: "Summary of jQuery Operation iframe 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: