jQuery Method for Getting and Setting iframe Height

  • 2021-07-06 10:08:41
  • OfStack

In this paper, the method of obtaining and setting the height of iframe by jQuery is described as an example. Share it for your reference, as follows:

Set the height of iframe, and the height of iframe is determined by the page height in iframe.

1. First get the height of the page in iframe:

var iframeHeight = $("#UpdateUserItem").contents().find("body").height();

2. Set the height of iframe:


$("#UpdateUserItem").height(iframeHeight);

Note: UpdateUserItem is ID of iframe;

When setting iframe height, you need to put this code on the same page as iframe.

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: