打开phonegap程序内的链接
大家好,我正在制作一个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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以尝试放置一个 iframe 并打开其中的链接吗?
you could maybe try putting an iframe and open the link in that?
在 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
我试图通过将 IFrame 嵌入应用程序(而不是在浏览器中打开)来完成类似的事情,这解决了我的问题。
在Xcode中,修改AppDelegate.m文件,
替换 shouldStartLoadWithRequest 部分
与此:
这适用于 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:
this is for Cordova 1.5.x,, on iOS obviously
使用 Phonegap 的
childbrowser
插件。这只会打开应用程序内部的链接。Use the
childbrowser
plugin for Phonegap. That will open the link inside the app only.