简体   繁体   English

这个奇怪的“脚本”在做什么?

[英]what is this strange “script” doing?

I am doing some test then find below code would pop up a window: 我正在做一些测试,然后发现下面的代码将弹出一个窗口:

<a href="script:test">test</a>

looks like it is trying to open an application. 似乎正在尝试打开应用程序。 Can anyone tell me what is the usage/purpose of this "script"? 谁能告诉我这个“脚本”的用途/目的是什么? looks like FF, Chrome, and IE all support it. 看起来FF,Chrome和IE都支持它。

script is being used as a protocol. script被用作协议。 No applications handle the script protocol, so clicking it does nothing useful. 没有应用程序处理script协议,因此单击它无济于事。

You can register a custom protocol handler and if the user accepts it, your application will be allowed to open all links of that type (there are only a few permitted protocols ): 您可以注册一个自定义协议处理程序,如果用户接受它,则您的应用程序将被允许打开该类型的所有链接( 只有少数允许的协议 ):

window.navigator.registerProtocolHandler('web+test', 'http://example.org/?handler=%s', 'Test Protocol');

Only example.org will be allowed to run the above code, but if you open your dev tools while visiting http://example.org/ and run the above code, you will get a dialog asking you to allow or deny the protocol association. 只允许example.org运行上述代码,但是如果您在访问http://example.org/时打开开发工具并运行上述代码,则会出现一个对话框,要求您允许或拒绝协议关联。 If you accept it, click the following link on any website: 如果接受,请在任何网站上单击以下链接:

<a href="web+test:hello">test</a>

It will redirect to http://example.org/?handler=hello 它将重定向到http://example.org/?handler=hello

Trying to open an application? 尝试打开应用程序? That script is just a hyperlink, it does not tell anything else in the script, just that it will open a link into site that tells "test" 该脚本只是一个超链接,它不会告诉脚本其他任何内容,只是会打开一个指向“测试”的站点链接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM