iframe embed元素 src="blob:http://localhost:8080/e3d44e31-8006-4efa-8c06-c26ba4cc0700"显示空白,但把blob:http://localhost:8080/e3d44e31-8006-4efa-8c06-c26ba4cc0700直接放在地址栏中能正常显示内容:这可能是因为在iframe的src属性中使用blob URL时,浏览器可能会出于安全考虑阻止加载。浏览器认为iframe中的内容来自不同的源,可能存在安全隐患。\n\n要解决这个问题,你可以尝试将blob URL转换为可信任的URL,例如使用createObjectURL方法创建一个Blob对象的URL。以下是一个示例代码:\n\njavascript\n// 通过fetch获取blob数据\nfetch('blob:http://localhost:8080/e3d44e31-8006-4efa-8c06-c26ba4cc0700')\n .then(response => response.blob())\n .then(blob => {\n // 创建blob的URL\n const url = URL.createObjectURL(blob);\n \n // 将blob URL设置为iframe的src属性\n const iframe = document.querySelector('iframe');\n iframe.src = url;\n });\n\n\n这样做将确保浏览器信任blob URL,并能够正常加载和显示内容。

iframe embed元素 src=

原文地址: https://www.cveoy.top/t/topic/p92e 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录