什么控制PhoneGap是否打开外部浏览器/ Safari? [英] What controls whether PhoneGap opens an external browser / Safari?

查看:130
本文介绍了什么控制PhoneGap是否打开外部浏览器/ Safari?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时,PhoneGap会在Safari中打开网页,有时会在其UIWebView中打开网页,这是什么控制?

解决方案

a href =http://stackoverflow.com/questions/3210543/does-phonegap-support-normal-web/3505350#comment10019245_3505350> phoneGap是否支持正常的网络?:



https:// github.com/callback/callback-ios/blob/master/PhoneGapLib/Classes/PhoneGapDelegate.m#L669 会显示:


  1. 如果网址有方案gap://不打开Safari

  2. 如果网址有方案file://不打开Safari
  3. li>如果设置了OpenAllWhitelistURLsInWebView策略,它不会打开Safari。
  4. if navigationType == UIWebViewNavigationTypeOther&&

详细说明4:




  • 〜NavTypeOther表示导航不是来自:链接点击,返回/ fwd按钮,重新加载或形成重新提交。 (AKA window.location.href assignment window.open(...)

  • mainDocument!= nil 表示链接不是来自iFrame的?


  • 所以基本上,我认为只有链接点击在UIWebView中打开(除非他们' re gap://或file:// links,或已设置该策略。)


    Sometimes PhoneGap opens web pages in Safari, sometimes it opens them in its UIWebView, what controls this?

    解决方案

    From Does phoneGap support normal web?:

    https://github.com/callback/callback-ios/blob/master/PhoneGapLib/Classes/PhoneGapDelegate.m#L669 reveals that:

    1. if the URL has scheme gap:// it does not open Safari
    2. if the URL has scheme file:// it does not open Safari
    3. if the OpenAllWhitelistURLsInWebView policy is set it does not open Safari.
    4. if navigationType == UIWebViewNavigationTypeOther && mainDocument != nil then it does open Safari.

    Elaborating on 4:

    • ~NavTypeOther signifies that the navigation is not from: a link click, back/fwd button, reload, or form re/submission. (AKA window.location.href assignment, or window.open(...))
    • mainDocument != nil signifies that the link is not from an iFrame? and/or doesn't have a target?

    So basically, I think that only link clicks open in the UIWebView (unless they're gap:// or file:// links, or that policy is set.)

    这篇关于什么控制PhoneGap是否打开外部浏览器/ Safari?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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