Is it possible to disable the internet of a tab in a browser using javascript and cut the connection to a server? Like disabling the outgoing connections in firewall.
Probably the simplest way you can simulate network errors is with Service Workers, by intercepting requests and hijacking the response with your own content:
self.addEventListener('fetch', event => event.respondWith(
event.request.url.matches(BLOCK) ? Response.error() : fetch(event.request)
));
Another viable approach, perhaps one that better conveys what is it that your actually attempting to accomplish, is by adding appropriate Content Security Policy directives. You could achieve this with your server, by adding them through response headers, statically in your HTML markup or by dynamically adding elements to the DOM.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With