javascript - 从 srcdoc 设置内容时的 iframe onload 事件
问题描述
如何为从属性加载的 iframe 指定 onloadsrcdoc
属性。例如:
<iframe id="Content" runat="server" srcdoc="Large HTML contents that are set from the server"></iframe>
我正在使用 asp.net 网络表单来填充来自另一台服务器的内容。
但是,触发 iframe 的 onload 的正常方法如下,但这不起作用:
$(function () {
var iframe = document.getElementById(DocumentViewer.GetFrameClientID());
console.log({iframe}) // OK
iframe.onload = function () { // Never Trigger unless i add a src attribute instead of srcdoc
console.log('loaded')
}
})
我发现 2018 年在 github 上报告的一个问题“加载”事件处理程序被提前为 iframe.srcdoc 调用
有什么线索吗?
解决方案
推荐阅读
- linux - 在bash中匹配逗号分隔列表中的单词
- c# - 如何使用 rest api 在 DocuSign 中创建信封的副本?
- keras - 如何解释等级为 3 的 Keras Dense 层
- sql - 如何使用 REGEXP_SUBSTR 函数从字符串中提取子字符串?
- visual-paradigm - 使用视觉范式 api 导出图像会引发 nullpointerexception
- tfs - 如何处理 TFS 中的剩余任务,以便燃尽图正确
- python - 如何修复列之间的空格分隔符
- java - 属性文件应该存储在 XPages 应用程序中的什么位置?
- javascript - 为什么我不能在 Node 中运行这个 MongoDB 查询,但它可以在社区指南针中运行?
- qt - qml controle 中的语言环境属性是什么?如何使用它?