如果命令嵌入在外部站点中,如何运行功能cordova? [英] How do I run a function cordova if the command embedded in external sites?

查看:95
本文介绍了如果命令嵌入在外部站点中,如何运行功能cordova?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想运行一个函数以在android浏览器系统中打开链接。这是我的问题的例证。 请参见插图什么我该怎么办?我只使用javascript而不使用Java。请帮助

I want to run a function to open the link in the android browser system. Here is an illustration of my questions. See the illustration What should I do? I only use javascript not java. Please help

推荐答案

前段时间,我遇到了同样的问题。为此,我修改了InAppBrowser源代码。
应该覆盖InAppBrowser.java中的InAppBrowserClient类中的shouldOverrideUrlLoading方法

Some time ago I encountered the same problem. To do this I modified the InAppBrowser source code. you should override the shouldOverrideUrlLoading method in the InAppBrowserClient class found in InAppBrowser.java

这将允许您在加载URL之前挂接到请求并选择其他行为。在您的情况下,在系统浏览器中加载URL。

This will allow you to hook in to the request before the url is being loaded and choose an alternate behavior. In your case loading the URL in the system browser.

您的代码将如下所示:

@Override
public boolean shouldOverrideUrlLoading (WebView view, String url){
    if(url.equals("Your URL to be loaded")){
        openExternal(url);
        return true;
    }
    return false;
}

这篇关于如果命令嵌入在外部站点中,如何运行功能cordova?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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