Can't capture network requests in iframe using service worker

344 views
Skip to first unread message

Shiva sandupatla

unread,
Mar 24, 2021, 11:04:45 AM3/24/21
to Khan Academy Javascript Technical Q&A
I am unable to intercept the fetch request from iframe using service worker

Firstly I have used iframe src  attribute to load my code, i.e.; http://localhost:3000/test.html

The test.html file contains an img tag of src, i.e.; /test.png , which doesn't exist in my folder.

Now the image fails to loads and the failed fetch request is captured by service worker.

Now I used iframe srcdoc,  putting same code as in the test.html. now when the image fails to load the service worker unable to capture the failed fetch request.

How can I achieve this or is there any method to do so.

Please guide me to implement.

Hoping with a positive response.

Regards, shiva and team

Reply all
Reply to author
Forward
0 new messages