/    Sign up×
Community /Pin to ProfileBookmark

can’t capture failed iframe request in iframe

Hey, 👋
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**

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@sibertMar 24.2021 — > @Shiva123456789#1629617 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


Is the Service Worker also on localhost? What happens if you make it live?

https://jsfiddle.net/mry6258o/
Copy linkTweet thisAlerts:
@Shiva123456789authorMar 26.2021 — @sibert#1629619 , thanks for your reply.

> @sibert#1629619 Is the Service Worker also on localhost? What happens if you make it live?

there is no use same bug.

But I want this using _srcdoc_ attribute
×

Success!

Help @Shiva123456789 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 3.29,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,

tipper: Anonymous,
tipped: article
amount: 10 SATS,
)...