Phonegap构建-在InAppBrowser或子浏览器中打开没有工具栏的外部页面并关闭它? [英] Phonegap build - Open external page in InAppBrowser or childbrowser with no toolbar and close it?

查看:108
本文介绍了Phonegap构建-在InAppBrowser或子浏览器中打开没有工具栏的外部页面并关闭它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  1. 我想在InAppBrowser或子浏览器中打开一个外部页面,在该页面中我不显示任何工具栏,并且在我的外部页面中可以有一个按钮来关闭浏览器并从我打开的位置返回到应用程序浏览器. 那么当您没有完成按钮时如何关闭? 我已经看到,如果我有 var ref = window.open(encodeURI(url),'_self','location = yes'); 然后可以使用ref.close()关闭浏览器;但是,如果我在打开的外部页面中使用它不起作用,是否没有关闭浏览器?

  1. I want to open an external page in the InAppBrowser or childbrowser, where I don't show any toolbar and where I can have a button in my externalpage that closes the browser and returns to the app from where I opened the browser. So how to close when you don ́t have a DONE button? I have seen that if I have var ref = window.open(encodeURI(url), '_self', 'location=yes'); then it is possible to close the browser with ref.close(); but if I use that in the externalpage that I opened it doesn't work, it is not closing the browser?

如果我在配置文件中将方向设置为纵向,是否有任何方法可以自动旋转它们?我知道您可以手动旋转子浏览器,而不是通过构建服务来自动旋转它.还是我必须将方向设置为两者?

Is there any way to autorotate any of them if I have set the orientation to portrait in the config file? I know that you can autorotate the child browser if you do it manually, not through the build service. Or do I have to set the orientation to both?

我已经测试了所有不同的方式来打开ChildBrowser和InAppBrowser,我真的看不到它们之间有什么大不同吗? InAppBrowser可以使用ChildBrowser无法使用的本机功能吗?

I have tested all different ways to open the ChildBrowser and the InAppBrowser and I cant really see any big difference between them? Can the InAppBrowser use native feature wile the ChildBrowser can't or?

推荐答案

好,解决了要关闭的问题1. 这就是我用来在InAppBrowser中打开外部页面的方法. 从我在InAppBrowser中加载的页面上,我可以关闭InAppBrowser本身,并从打开浏览器的位置返回我的应用.

OK, problem 1 to close is solved. This is what I use to open an external page in the InAppBrowser. From the page that I load in the InAppBrowser, I can close the InAppBrowser itself, returning to my app from where I opened the browser.

在服务器上创建一个页面-closeInAppBrowser.html只是一个空的html页面,它什么也没做

Create a page on your server - closeInAppBrowser.html that is just an empty html page, it doesn´t do anything

我用以下方法打开浏览器:

I open the browser with this:

<a href="#" onclick="openInAppBrowserBlank('http://www.mypage.asp?userId=1');">open InAppBrowser</a>

var ref = null;
function openInAppBrowserBlank(url)
{
    try {
ref = window.open(encodeURI(url),'_blank','location=no'); //encode is needed if you want to send a variable with your link if not you can use ref = window.open(url,'_blank','location=no');
         ref.addEventListener('loadstop', LoadStop);
         ref.addEventListener('exit', Close);
    }
    catch (err)    
    {
        alert(err);
    }
}
function LoadStop(event) {
         if(event.url == "http://www.mypage.com/closeInAppBrowser.html"){
            // alert("fun load stop runs");
             ref.close();
         }    
    }
function Close(event) {
         ref.removeEventListener('loadstop', LoadStop);
         ref.removeEventListener('exit', Close);
    } 

要从浏览器中打开的页面关闭InAppBrowser( http://www.mypage.asp ),我有这样的按钮链接.

And to close the InAppBrowser from the page that I opened in the browser(http://www.mypage.asp) I have a button-link like this.

<a href="http://www.mypage.com/closeInAppBrowser.html"></a>

我希望它对其他人有帮助!

I hope it helps somebody else!

这篇关于Phonegap构建-在InAppBrowser或子浏览器中打开没有工具栏的外部页面并关闭它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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