[英]Can an iframe render offline with a service worker?
I have my domain, abc.com
, and an iframe inside my page 123.com
. 我的网页123.com
有我的域名, abc.com
和iframe。 I own the code for each domain. 我拥有每个域的代码。
With a service worker I can load abc.com
while offline but my iframe for 123.com
does not load, even if I add its files to my cache.addAll
call. 对于服务工作者,我可以在离线时加载abc.com
但是我的iframe for 123.com
无法加载,即使我将其文件添加到我的cache.addAll
调用。
How can I get my iframe to render while offline? 如何在离线时让我的iframe呈现? Examples welcome. 欢迎举例。
<!DOCTYPE html>
<html>
<head></head>
<body>
will render offline
<!-- will not render offline -->
<iframe src="123.com"></iframe>
</body>
</html>
Loading an <iframe>
is very similar to loading a full page in a new tab/window. 加载<iframe>
与在新标签/窗口中加载整页非常相似 。 The request for the <iframe>.src
will trigger any fetch
handlers on a service worker whose scope covers the <iframe>.src
, ie in your case, a service worker whose scope covers https://123.com/
. 对<iframe>.src
的请求将触发服务工作者上的任何fetch
处理程序,其范围涵盖<iframe>.src
,即在您的情况下,其范围涵盖https://123.com/
的服务工作者。
The FetchEvent
that's passed to the fetch
handler will have a request.mode
of 'navigate'
, just like a navigation to a new page in a standalone tab/window would have. 传递给fetch
处理程序的FetchEvent
将具有'navigate'
的request.mode
,就像导航到独立选项卡/窗口中的新页面一样。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.