Intercept URL before unload with javascript or jquery -


i'm writing simple chrome plugin intercept new url before page unload , if contains specific string want actions , invalidate redirect! have no idea how do.. can me?

you can use onbeforerequest event of webrequest api chrome extensions:

chrome.webrequest.onbeforerequest.addlistener(     function(details) {          // actions         // ...         return {cancel: true};      },     // block requests matching url     {urls: ["*://www.evil.com/*"]},     ["blocking"] ); 

just make sure have right permissions in manifest.json file:

you must declare "webrequest" permission in extension manifest use web request api, along host permissions hosts network requests want access.

"permissions": [     "webrequest",     "webrequestblocking",     "*://*.google.com" ], 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Socket.connect doesn't throw exception in Android -

iphone - How do I keep MDScrollView from truncating my row headers and making my cells look bad? -