问题
What could be the best way the detecting the custom protocol (like foo://) in Safari and chrome browser. I was looking at the following options:
Browser extension which can check the existence of custom protocol invoker software. (Not sure if it is possible and how to do it)
Browser plugin or java applets( since NPAPI is now going to deprecated so probably this will not be good idea).
Flash Action script with java script(since Flash is sand boxed then again it seems not good idea to use it)
Can any one suggest any other approach or suggestion? can I go by approach #1.
回答1:
You should be able to detect the custom protocol by relying only on Javascript.
I've found the following project for protocol detection using Javascript, hope it helps: https://gist.github.com/rajeshsegu/3716941
You can check more information in this related question: How to detect browser's protocol handlers?
来源:https://stackoverflow.com/questions/27489665/approaches-of-detection-of-custom-protocol-in-chrome-and-safari-browsers