您可以将response.text()
渲染为(如果您愿意,可以使用visibility: hidden
)。然后你就可以与所有的标准功能,操作新的文档:
<!DOCTYPE html>
<html>
<head>
<title>This is the page title</title>
<meta charset="UTF-8">
<meta name="description" content="Free Web Help">
<meta name="keywords" content="HTML,CSS,XML,JavaScript">
<meta charset="utf-8">
</head>
<body>
</body>
<script>
var img = new Image();
img.src = "http://cdn.sstatic.net/stackoverflow/img/[email protected]";
document.body.appendChild(img);
fetch("so.html")
.then(function(response) {
return (response.text());
})
.then(function(responseText) {
// limit the recursion depth to 1
if (!window.frameElement) {
var newDoc = document.createElement('iframe');
document.body.appendChild(newDoc);
newDoc.contentDocument.write(responseText);
}
});
</script>
</html>
自己试用,您可以将此代码保存为so.html
,并访问您的本地Web服务器上,或者你可以check it out here。
如果您添加了“Javascript”标签,您是否认为您可能会从社区获得更好的回复? –
yeap。你是对的......)完成。 – jack
@Kkinsey任何答复我的问题btw? ;) – jack