使用javascript关闭移动浏览器标签 [英] Closing a mobile browser tab with javascript

查看:138
本文介绍了使用javascript关闭移动浏览器标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个本机应用程序来启动带有某些URL的浏览器,该URL会将用户带到移动网站.在移动网站内部,必须有一个关闭浏览器的按钮(或将任何信号发送到本机应用程序),以便用户返回到本机应用程序.目前,我正在尝试关闭窗口,但我认为这不会在所有移动设备上都成功.

I need a native app to fire a browser with some URL that will take the user to a mobile website. Inside the mobile website, there has to be a button that closes the browser (or sends any signal to the native app) so that the user gets back to the native app. Currently I'm trying to close the window, but I don't think that's gonna do the trick in all mobile devices.

我的代码:

$( document ).bind('pageinit', function(){
   $.mobile.activePage.find('#close').click(function(){
      window.open('', '_self', ''); 
      window.close();
   });
});

我正在使用jQuery mobile.

I'm using jQuery mobile.

推荐答案

设置自定义URI处理程序(

Setup a custom URI handler (for Android and for iOS). Then all you have to do is redirect to a URL that matches, perhaps using window.location.

这篇关于使用javascript关闭移动浏览器标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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