0

Can I detect a redirection happening in a browser, which is not pointed to HTTP(s) protocol?

For example, my script redirects to something like ftp://, sms://, ws:// using

location.href=ws://abc/a

Is there a way to detect such redirection using JS? If useful, I can involve chrome ext environment in this as well.

Srikanth Rayabhagi
  • 1,393
  • 3
  • 12
  • 23
  • I would suggest using onbeforeunload event; unfortunately i don't think this is easily achieved. http://stackoverflow.com/questions/1686687/how-can-i-get-the-destination-url-in-javascript-onbeforeunload-event – trainoasis May 18 '14 at 13:32

1 Answers1

1

Though this is not straight away, if you are using chrome extension, you can rely on chrome.webRequest.onHeadersReceived.* API which would give some clue via responseHeaders and you can detect the non-http redirects and setup actions accordingly.

Srikanth Rayabhagi
  • 1,393
  • 3
  • 12
  • 23