简体   繁体   English

停止将IE / Edge窗口调整为iframe尺寸

[英]Stop IE/Edge window resize to iframe dimensions

The problem: When loading content into an iframe via an AJAX call, IE/Edge resizes the browser window to the width and height of the iframe instead of keeping the original dimensions. 问题:通过AJAX调用将内容加载到iframe中时,IE / Edge会将浏览器窗口的大小调整为iframe的宽度和高度,而不是保持原始尺寸。 The iframe contains <html><body> tags and so on. iframe包含<html><body>标记等。

在此处输入图片说明

 <iframe id="main" name="main" frameborder="0" width="100%" height="600" style="height: 600px !important; width: 100% !important;" scrolling="no" src="/en/courseid2900"> #document <!DOCTYPE html> <html></html> </iframe> 

(before AJAX call in IE/Edge) (在IE / Edge中的AJAX调用之前)

在此处输入图片说明

 <iframe id="main" name="main" frameborder="0" width="100%" height="" style="height: 696.796875px" scrolling="no" src="/en/courseid2900"> #document <!DOCTYPE html> <html lang="en-US" class=" -webkit-">...</html> </iframe> 

(after AJAX call in IE/Edge) (在IE / Edge中的AJAX调用之后)

So, is there a way how to block the resizing of the window to the iframe dimensions? 因此,有没有一种方法可以阻止将窗口调整为 iframe尺寸? Can it be done via jQuery or a HTML hack? 可以通过jQuery或HTML hack完成吗? Thanks. 谢谢。

Iframe elements may not contain any content so the code you show in your post is 100% incorrect HTML. iframe元素可能不包含任何内容,因此您在帖子中显示的代码是100%不正确的HTML。 If you want content in an iframe, you either point it to a real URL using the src attribute, or you manually construct an iframe DOM node in JavaScript and then insert that into your document. 如果要在iframe中使用内容,则可以使用src属性将其指向真实的网址,或者在JavaScript中手动构造iframe DOM节点,然后将其插入文档中。

Any content that you put inside an iframe element as markup rather than through DOM manipulation through JS is by definition of the iframe element treated as parent document content. 您将iframe元素内的所有内容标记为标记,而不是通过JS通过DOM操作将其内容定义为父文档内容。 Doing what your post suggests, you've created a document with two <html> sections and it's not too surprising that browsers are going to do wildly incorrect things: you did something wildly incorrect =) 按照您的帖子所建议的,您已经创建了一个包含两个 <html>部分的文档,并且浏览器将执行完全错误的操作也就不足为奇了:您所做的操作完全错误=)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM