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 -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -