How exactly can I replace an iframe with a div and Javascript?

前端 未结 5 1924
再見小時候
再見小時候 2020-12-28 20:03

I have a page that loads an external HTML page into an iFrame. There are two problems I am facing with this:

  1. The iFrame is always a fixed height, but I want it
5条回答
  •  孤城傲影
    2020-12-28 20:40

    I am asking how to replace an iframe with a DIV and Javascript in order to get the functionality I mention above. I am not looking for ways to make iFrames behave differently.

    If you want the functionality mentioned you don't have to replace the iframe. The functionality 2 is easier with an iframe. As for functionality 1, you have two choices:

    1. Put your iframe in a DIV and play with css rules like position absolute and relative plus height at 100%

    2. Add a javascript function to handle the resize event of the window object to resize the iframe

提交回复
热议问题