Old-fashioned questions,The overwhelming solution on the network, as well as the copy-and-transfer "blog", mainly describes a specific problem in IE8 today.
Function Autosetframeheight (name ){ Try { VaR IFRAME; If (! Name) Return ; IFRAME = Document. getelementbyid (name ); If (IFRAME. contentdocument) $ ( "#" + Name). Height (IFRAME. contentdocument. height + "PX" ); Else $ ( "#" + Name).height(document.frames?name=.doc ument. Body. scrollheight + "PX" );} Catch (E ){ // Alert (E. Message ); }}
User response todayIE8Next pop-up window(IFRAMEEmbedded small page)Incomplete display,After testing,IFRAME. contentdocument. HeightInIE8 is invalid in IE6-7, chrome, firefox3 ~ 4 lower
ChangeIFRAME. contentdocument. Body. offsetheightLater, in IE6-8, chrome, firefox3 ~ 4. The test passes.
ExampleCodeRunning in real projects,HoweverIFRAMEThe content on the target page is relatively simple.,Therefore, it is not tested.IFRAMEThe target page contains the absolute positioning layer./Fold,And the situation that includes the float layer,
And someArticleMentioned"NonIEThe browser will be too tall to scale back"..Please note.
Additional information:(You are requested to manually upload the original content of the certificate, which is accepted by the certificate)
- http://www.cnblogs.com/yuhe7919/archive/2009/11/04/iframe.html
- http://blog.pchome.net/article/194139.html
example of Token Generation mentioned in this article , I suggest you stop using it, if the first line takes the height of the Token because of the compatibility issue of the receiver, the token is completely invalid. in addition, there is no intention of using two highly comparable methods, and some of them have a poor sense.
try {
v ar bheight = iframe.content?#doc ument. body. scrollheight;
var dheight = iframe.content##document.doc umentelement. scrollheight;
}catch (Ex) {}