最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Get custom protocol response - Stack Overflow

programmeradmin1浏览0评论

I was learning about custom protocols for few days, and there's one thing that I don't understand. I know how to start an app with custom protocol, but My question is,
Is it possible to get apps response and print it in Web Browser using javascript?
For example If I will send request to protocol myapp:// , that will open an app written in C#, and that app will return string "This is response" can to print it in Web Browser?
If so, can you help me to acplish it?
Thanks in advance.

I was learning about custom protocols for few days, and there's one thing that I don't understand. I know how to start an app with custom protocol, but My question is,
Is it possible to get apps response and print it in Web Browser using javascript?
For example If I will send request to protocol myapp:// , that will open an app written in C#, and that app will return string "This is response" can to print it in Web Browser?
If so, can you help me to acplish it?
Thanks in advance.

Share Improve this question asked Nov 13, 2012 at 21:10 René BenešRené Beneš 4882 gold badges13 silver badges29 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 4

Internet protocols aren't all about browsers.

mailto: causes an action in an email program (e.g. start a new email)

ftp: causes an action in an FTP program (which might be integrated into a web browser or Windows Explorer)

gopher: (well, that's not really prevalent anymore)

myapp:// will cause your (C#) app to start running. At that point, it can do anything a C# app can do. One thing it could choose to do is create a .html file on disk, and use

Process.Start("file://Path/To/My.html")

to cause the default web browser to open the document it just created.

UPDATE

You can certainly have your myapp:// protocol handler send an update to the web server that hosts the page in question. My assumption here is that the myapp:// handler is running on a client machine, and there is a web server on a different URL http://mydomain. serving a page that includes a myapp:// reference.

  1. Web server renders a page that includes both a myapp:// URL and Ajax code to periodically query the web server for updates to part of the HTML body.
  2. User clicks the myapp:// URL
  3. Protocol handler runs
  4. Protocol handler sends an update to the web server, e.g. http://mydomain.?user=joe&result=123
  5. Web server uses ?user=joe&result=123 to update response next time the Ajax callback is initiated
  6. Ajax callback gets updated data for page from web server, updates page.
发布评论

评论列表(0)

  1. 暂无评论