是否有可能与谷歌Chrome浏览器打开自定义URL方案? [英] Is it possible to open custom URL scheme with Google Chrome?

查看:723
本文介绍了是否有可能与谷歌Chrome浏览器打开自定义URL方案?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有协议(如HTTP)与方案,在Mac OS X上注册的第三方应用程序管理 即X-someapp:// someaction或类似的东西。

I have protocol (like http) with scheme managed with 3rd party App registered in Mac OS X. I.e, x-someapp://someaction or something like that.

我怎样可以打开这个网址与谷歌浏览器? 默认情况下,Chrome浏览器开始搜索在谷歌引擎,而不是启动应用程序,并通过URL处理它...

How can I open this URL with Google Chrome? By default, Chrome starts searching in Google engine instead launching App and passing URL handling to it...

Safari浏览器推出了一些注册应用程序。它是正确的事情。

Safari launches some registered App. And it is right thing.

Firefox和Opera问该怎么办...我可以启动应用程序也。

Firefox and Opera asks what to do... and I can launch App also.

但是,Chrome浏览器...不问。

But Chrome... Doesn't ask.

我甚至试着写的JavaScript里面的一些HTML页面发送XHtt prequest:

I even tried to write some HTML page with JavaScript inside to send XHttpRequest:

function _httpExecuteCallback()
{
 if (httpRequestCallbackFunction != null) {
  if (httpRequest.readyState == 4) {
   if (httpRequest.status == 200) {
    httpRequestCallbackFunction();
    httpRequestCallbackFunction = null;
   }   
  }
 }
}

function _httpGet(url, callbackFunction)
{
 httpRequest = false;
 httpRequestCallbackFunction = callbackFunction;
 httpRequest = new XMLHttpRequest();
 httpRequest.onreadystatechange = _httpExecuteCallback;
 httpRequest.open('GET', url, true);
 httpRequest.send(null);
}


_httpGet('x-someapp://test',function(){})

没有结果还...

推荐答案

我发现,Chrome浏览器的工作方案。 我用IFRAME路。

I found the solution that works with Chrome. I use the IFRAME-way.

为例(使用jQuery):

Example (with JQuery):

$("body").append('<span id="__protoProxy"></span>');

function queryWord(aWord)
{
 var protoProxy = document.getElementById('__protoProxy');
 if (protoProxy)
 {   
  var word = aWord.replace('"','\"');
  protoProxy.innerHTML = '<div style="display:none;"><iframe src="x-myproto://query?' + word + '"></iframe></div>';
 }
}

queryWord('hello');

这篇关于是否有可能与谷歌Chrome浏览器打开自定义URL方案?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆