打开phonegap程序内的链接

发布于 2024-12-09 13:45:35 字数 240 浏览 0 评论 0原文

大家好,我正在制作一个phonegap + jquery移动程序,问题是我在phonegap中有一个列表视图,正在由外部站点加载,在列表的叶子中有一个指向带有以下内容的站点的href:我想在程序中打开html。当我单击叶子时,它会在移动浏览器中打开链接而不是手机间隙程序,我想让它打开程序内部的链接而不是移动浏览器。

我已经尝试过 rel=external 和 data-ajax="false" 但一切都失败并在移动浏览器中打开,有人可以帮助我吗?

Hi guys I'm making a phonegap + jquery mobile program, the problem is that I've got a listview in the phonegap that is being loaded by an external site, in the leaf of the list have an a href to a site with the html that i want to be opened in the program. When I click in the leaf it opens the link in the mobile browser instead of the phonegap program, and I would like to make it open the links inside the program instead of the mobile browser.

I've already tried rel=external and data-ajax="false" but everything is failing and opening in the mobile browser, can some one help me please?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

护你周全 2024-12-16 13:45:35

您可以尝试放置一个 iframe 并打开其中的链接吗?

you could maybe try putting an iframe and open the link in that?

趁微风不噪 2024-12-16 13:45:35

在 Android 中执行此操作的方法如下:

iPhone 版 PhoneGap:加载外部 URL 时出现问题

iOS 也存在类似的机制。您可以在 PhoneGap.plist 中指定不应在外部浏览器中启动的外部 URL

Here's how you'd do it in Android:

PhoneGap for iPhone: problem loading external URL

A similar mechanism exists for iOS. You can specify external URLs that should not be launched in an external browser in PhoneGap.plist

飘逸的'云 2024-12-16 13:45:35

我试图通过将 IFrame 嵌入应用程序(而不是在浏览器中打开)来完成类似的事情,这解决了我的问题。
在Xcode中,修改AppDelegate.m文件,
替换 shouldStartLoadWithRequest 部分
与此:

- (BOOL)webView:(UIWebView *)theWebView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
    NSURL *url = [request URL];
    if ([[url scheme] isEqualToString:@"http"] || [[url scheme] isEqualToString:@"https"]) {
        return YES;
    }
    else {
        return [ self.viewController webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType ];
    }
}

这适用于 Cordova 1.5.x,显然在 iOS 上

I was trying to accomplish a similar thing by making IFrames embed in the app (instead of opening in a browser )and this fixed the issue for me .
In Xcode, modify the AppDelegate.m file,
replace the shouldStartLoadWithRequest section
with this:

- (BOOL)webView:(UIWebView *)theWebView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
    NSURL *url = [request URL];
    if ([[url scheme] isEqualToString:@"http"] || [[url scheme] isEqualToString:@"https"]) {
        return YES;
    }
    else {
        return [ self.viewController webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType ];
    }
}

this is for Cordova 1.5.x,, on iOS obviously

流年已逝 2024-12-16 13:45:35

使用 Phonegap 的 childbrowser 插件。这只会打开应用程序内部的链接。

Use the childbrowser plugin for Phonegap. That will open the link inside the app only.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文