dsdfd2322 2014-08-28 16:53
浏览 78
已采纳

一次加载两个HTML文档(从字符串加载iframe内容)

I have a rather strange need. I need to be able to render two documents at once in the same browser window, but it is not as simple as it sounds.

In the framework that I'm using, enabling debug mode will cause errors to render as an HTML document, displaying a pretty error report page, however there is also the non-debug mode page that I want to display as well with a button to switch between the two.

Basically I have this idea that if I could use an iframe, but input a raw string inside it instead of loading an URL that would be exactly what I'm looking for. Is something like this possible?

  • 写回答

1条回答 默认 最新

  • doubi1928 2014-08-28 16:57
    关注

    You can do this, but you have to be careful to escape your string.

    <iframe src="javascript: '<html><head><title>iframe</title></head><body>IFRAME</body></html>'"></iframe>
    

    The string inside the single quotes must be escaped properly for this to work.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 itunes恢复数据最后一步发生错误
  • ¥15 关于#windows#的问题:2024年5月15日的win11更新后资源管理器没有地址栏了顶部的地址栏和文件搜索都消失了
  • ¥15 看一下OPENMV原理图有没有错误
  • ¥100 H5网页如何调用微信扫一扫功能?
  • ¥15 讲解电路图,付费求解
  • ¥15 有偿请教计算电磁学的问题涉及到空间中时域UTD和FDTD算法结合的
  • ¥15 vite打包后,页面出现h.createElement is not a function,但本地运行正常
  • ¥15 Java,消息推送配置
  • ¥15 Java计划序号重编制功能,此功能会对所有序号重新排序,排序后不改变前后置关系。
  • ¥15 关于哈夫曼树应用得到一些问题