我需要在不使用iframe
元素的情况下将一个响应式网站加载到我的超文本标记语言页面的div中。
我已经尝试过this link;它可以处理我在脚本中提到的单个页面的URL。
$('#mydiv').load('http://localhost/qa/ask#external-div', function(response, status, xhr) {
if (status == "error") {
var msg = "Sorry but there was an error: ";
alert(msg + xhr.status + " " + xhr.statusText);
}
});
发布于 2013-08-09 19:09:06
使用简单的html,
<div>
<object type="text/html" data="http://validator.w3.org/" width="800px" height="600px" style="overflow:auto;border:5px ridge blue">
</object>
</div>
或者jquery,
<script>
$("#mydiv")
.html('<object data="http://your-website-domain"/>');
</script>
发布于 2021-03-10 15:22:22
正如这个堆栈溢出线程中所提到的,difference between iframe, embed and object elements
您可以使用tag,而不是tag。如果需要在子项和父项之间进行通信。
†在下面的注释中指出;中的脚本将运行,但父上下文和子上下文无法直接通信。使用,您可以从父对象获取子对象的上下文,反之亦然。这意味着你可以在父进程中使用脚本来操作子进程等等。这部分是不可能的,或者你必须设置一些其他的机制,比如JavaScript postMessage应用程序接口。
<embed type="text/html" src="snippet.html" width="500" height="200">
https://stackoverflow.com/questions/18145273
复制相似问题