Can iframe render offline using worker?
I have a domain abc.com
and an iframe inside my page 123.com
. I own the code for each domain.
With a service worker, I can load abc.com
while offline, but my iframe for 123.com
won't load even if I add its files to my call cache.addAll
.
How can I get the display of an iframe offline? Examples are appreciated.
<!DOCTYPE html>
<html>
<head></head>
<body>
will render offline
<!-- will not render offline -->
<iframe src="123.com"></iframe>
</body>
</html>
source to share
Loading is <iframe>
very similar to loading a full page into a new tab / window. The request for <iframe>.src
will trigger any handlers fetch
for a worker whose scope covers <iframe>.src
, i.e. In your case, the service worker whose area it covers https://123.com/
.
FetchEvent
passed to the handler fetch
will have request.mode
from 'navigate'
, as well as navigating to a new page in a separate tab / window.
source to share