我想捕捉load,即使是在加载页面后的某个时候附加在文档上的任何iframe。
我试过使用on("load", "iframe", fn),但这似乎不起作用:
function addIframe() {
$("<iframe src='https://example.com'>").appendTo($("body"))
}
// This does not work
$(document).on("load", "iframe", function() {
我看到了这里给出的响应: How to rightly detect iframe was loaded with response 204 No Content? 但这并不管用。 是否可以检查(使用事件,而不是检查iframe的内容),iframe是否已加载(请求已发送)? 示例: stackblitz
我希望我的网站加载第一部分,而不是整个页面,但当我给滚动加载该部分的内容。
|-------------------|
| Navigation bar | first part (width 100% and height: 750px;)
| H1 |
| Button |
|___________________|
|-------------------|
| A lot of iframes |
| and images | content (width: 100%)
|
我已经建立了一个投资组合网站,其中包含一个iFrame,以显示艺术品。为了显示每个艺术品,一个包含大图像的html页面被加载到iFrame中。
iFrame是隐藏的,而不是空的(display:none),只有当内容被完全加载时才会淡出。
//pass url of artwork page to iFrame
$("#creativeiframe").attr('src', thisLink.attr('href'));
//fade up iFrame once content loaded
$('#creativeiframe
我试图创建真正简单的Iframe在角2项目。
如果我在iframe中使用原始url,则获得一个错误unsafe value used in a resource URL context。
<!-- 1) Error : unsafe value used in a resource URL context -->
<iframe (load)="yourLoadFunction()" [src]="'/'" frameborder="0" width="1000px" height="50