Set iframe to height of content for remote content

后端 未结 6 1949
时光取名叫无心
时光取名叫无心 2021-01-12 11:59

The question of how to make your iframe fit 100% of your content (using JavaScript) has been answered on the forum already... for iframes displaying content from the sam

6条回答
  •  青春惊慌失措
    2021-01-12 12:24

    This is theoretical as I have not tested it:

    1) PHP save the remote page into a local html file using file_get_content() or using CURL. 2) Javascript load local file into iframe - it's now local and security issues don't apply.

    If there are javascript vars or Session vars (which cannot be pulled from remote content) you can at least use this technique to query the document height of your local file, set the iframe accordingly, then load the remote URL into the resized iframe.

    Cavat: you have no way of knowing URLs for page changes within the remote page, therefore you can only use this technique on the first page. If the remote pages are all same height this is no problem.

提交回复
热议问题