停止在新选项卡中打开自定义协议 [英] Stopping custom protocols opening in new tab

查看:71
本文介绍了停止在新选项卡中打开自定义协议的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自定义协议的网址(即myproto:// dosomething),我可以让它工作,但当用户点击网址时,它重定向页面,然后弹出你想打开这个网址吗?对话。

Ive got a url to a custom protocol (i.e. myproto://dosomething) and i can get it to work but when a user clicks on the url it redirects the page before popping up the "do you want to open this url" dialog.

有没有办法让自定义协议不用重定向?

Is there any way to have the custom protocol to work with out the redirect?

例如:

页面:

<html>
<body>
<a href="myproto://dosomething">My Url</a>
</body>
</html>

当用户点击链接时,浏览器会重定向到空白页面,其中myproto:// dosomething为url并显示弹出窗口。我试图做的就是让弹出窗口显示但保留在主页面上。

When user clicks link, browser redirects to blank page with myproto://dosomething as url and shows popup. What im trying to do is have it so that the popup shows but stays on the main page.

推荐答案

所以我找到了解决方案到这个问题:iframes

So i found a solution to this issue: iframes

var launchLink = function(href) {
    var url = ProtoRedirectUrl + '?' + $.param({ url: href });
    $('<iframe src="' + url + '" width="1px" height="1px">').appendTo('body');
}

这会导致加载网址,浏览器会将iframe窗口重定向到空白页而不是主窗口。

This causes the url to be loaded and the browser redirects the iframe window to the blank page instead of the main window.

这篇关于停止在新选项卡中打开自定义协议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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