字符串元素转 Blob URL

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>

	<script>
		iframe = document.createElement('iframe');
		iframe.src = URL.createObjectURL(new Blob(["<div>我是div</div>"],{type:'text/html'}));
		document.body.appendChild(iframe);
	</script>

</body>
</html>

在这里插入图片描述

发布了139 篇原创文章 · 获赞 24 · 访问量 10万+

猜你喜欢

转载自blog.csdn.net/mbh12333/article/details/103614801