![](/img/trans.png)
[英]Resize of Iframe dynamically depending on the content of the Iframe of the Iframe's src URL
[英]Altering IFrame src content
我不相信可以做到这一点,但是有可能更改通过src呈现的iframe的内容。
我使用的第三方编译的ASP.Net控件(Telerik RadEditor .Net 2版本)在其呈现代码的一部分中包含iframe,并且不包含doctype,并且在IE8中使用某些元素会引起问题。
由于已编译,因此无法在源代码中添加它。 我想知道是否可以通过其他方式添加它?
我在jquery中尝试了多种方法,例如:
$(element).html().prepend("doc type here");
$(element).html("doctype here" + $(element).html());
以及其他各种狡猾的工作。
src
是指内容,对不对? ( src
是iframe的属性,它指定iframe本身的URI)
您可以通过更改iframe 的内容来更改文档类型。 一种可能的方法是在添加doctype的同时重新创建iframe并重新插入内容。 不幸的是, 无法使用DOM在现有的iframe之前添加文档类型。
例:
var iframe = document.createElement("iframe");
var idocument = iframe.contentDocument;
idocument.open();
idocument.write("<!DOCTYPE html...") // Doctype goes here
idocument.write("<html>...</html>") // Content goes here
idocument.close();
我使用jQuery使用iframe完成了类似的domethin: $('iframe').contents().find("#internaldiv")
,但是只有在iframe src和主网站属于同一域的情况下,在其他情况下,您必须处理相同的域策略 ( http://en.wikipedia.org/wiki/Same-origin_policy ),并在服务器和另一台域服务器中实施跨域策略。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.