我有一个iframe,这个iframe的内容发生了变化,因此窗口可以更大或更小,所以我添加了一个自动调整大小的脚本。
此脚本工作正常,但只有当内容较大时,如果内容发生变化并且小于上次,则窗口不会调整大小并且高度相同。
我不知道出了什么问题。如果您有任何想法会很好。
还有我的脚本和我的iframe:
function autoResize(id){
var newheight;
var newwidth;
if(document.getElementById){
newheight=document.getElementById(id).contentWindow.document.body.scrollHeight;
newwidth=document.getElementById(id).contentWindow.document.body.scrollWidth;
}
document.getElementById(id).height=(newheight) + "px";
document.getElementById(id).width=(newwidth) + "px";
}
$(function(){
var f=$('#foo')
f.load(function(){
f.contents().find("body").on('click', function(event) {
runAfterTimeout('foo');
});
})
})
function runAfterTimeout(id) {
setTimeout(function(){
autoResize(id);
},1000);
};
我的iframe:
<iframe height="300px" width="100%" id="foo" src="" style="border: 0px currentColor; border-image: none;" onload="autoResize('foo')"></iframe>
答案 0 :(得分:1)
我认为每次调用onload时都需要重置iframe的高度。试试这个:
#3. Crashed: com.apple.root.default-qos
0 libFontParser.dylib 0x2467fef8 TType1Font::GetGlyphsPerCharacters(unsigned short const*, unsigned short*, unsigned int&, bool) const + 211
1 libFontParser.dylib 0x2466e45d TFPFont::GetXHeightAndCapHeightByAverageGlyphHeights(FPFontInfo&) const + 72
2 libFontParser.dylib 0x2466e45d TFPFont::GetXHeightAndCapHeightByAverageGlyphHeights(FPFontInfo&) const + 72
3 libFontParser.dylib 0x2466d4c7 TFPFont::FillFontInfo(TFPFontInfo&) const + 762
4 libFontParser.dylib 0x2466d149 TFPFont::GetFontInfo() const + 108
5 libFontParser.dylib 0x2466d0c9 FPFontIsMonospaced + 8
6 CoreGraphics 0x2386cf31 get_font_info + 208
7 CoreGraphics 0x2381bbe9 get_font_info + 36
8 CoreGraphics 0x2381bc1d CGFontGetUnitsPerEm + 8
9 CoreGraphics 0x237f0d53 get_glyph_bounding_box + 22
10 CoreGraphics 0x237f0a57 draw_glyph_bitmaps + 642
11 CoreGraphics 0x237efeb3 ripc_DrawGlyphs + 1074
12 CoreGraphics 0x2381b7f7 draw_glyphs + 834
13 CoreGraphics 0x2377b811 simple_draw + 220
14 CoreGraphics 0x2377b59f CGPDFTextLayoutDrawGlyphs + 74
15 CoreGraphics 0x236de265 op_Tj + 48
16 CoreGraphics 0x238b02f9 pdf_scanner_handle_xname + 72
17 CoreGraphics 0x238afe6d CGPDFScannerScan + 384
18 CoreGraphics 0x238b6f83 CGPDFDrawingContextDrawPage + 390
19 CoreGraphics 0x236d411f pdf_page_draw_in_context + 86
20 CoreGraphics 0x235e8c37 CGContextDrawPDFPage + 38
21 ------ 0x256635 -[----- drawLayer:inContext:] (------.m:107)
22 QuartzCore 0x24bfc325 -[CALayer drawInContext:] + 228
23 QuartzCore 0x24ce7017 tiled_layer_render(_CAImageProvider*, unsigned int, unsigned int, unsigned int, unsigned int, void*) + 1454
24 QuartzCore 0x24c2ab99 CAImageProviderThread(unsigned int*, bool) + 472
25 libdispatch.dylib 0x2211f6a1 _dispatch_root_queue_drain + 1572
26 libdispatch.dylib 0x2211f07b _dispatch_worker_thread3 + 94
27 libsystem_pthread.dylib 0x222b2e0d _pthread_wqthread + 1024
28 libsystem_pthread.dylib 0x222b29fc start_wqthread + 8