Phonegap 1.7中的Childbrowser插件只能第一次打开 [英] Childbrowser plugin in Phonegap 1.7 can open only for the first time

查看:190
本文介绍了Phonegap 1.7中的Childbrowser插件只能第一次打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Phonegap 1.7中的Childbrowser插件只能第一次打开。我使用Phonegap 1.7和Childbrowser。只有第一次儿童浏览器正在工作。

Childbrowser plugin in Phonegap 1.7 can open only for the first time. I'm using Phonegap 1.7 and Childbrowser. Only for the first time child browser is working. After I closed the Childbrowser (pressed the done button) it's not opening again when I tried to open it.

我的代码是这样的:

$("a[target=_blank]").bind('click', function(e) {
  e.preventDefault();
  var thisUrl = $(this).attr('href');
  cb.showWebPage(thisUrl);
  alert("click");
}); 

当我点击链接时,Childbrowser弹出并显示页面。我点击完成并返回。但是当我点击链接或其他链接时,Childbrowser不再弹出,但每次都会显示警告点击。

When I click a link, the Childbrowser pops up and shows the page. I click "Done" and return. But when I click the link or another link, the Childbrowser doesn't pop any more, but the alert "click" shows every time.

p.s。我从此处下载了Childbrowser插件

p.s. I downloaded the Childbrowser plugin from here

推荐答案

我也有这个问题,与Cordova 2.0.0,结合jQuery Mobile 1.1.1。我的代码设置我的链接看起来像:

I also had this issue, with Cordova 2.0.0, in conjunction with jQuery Mobile 1.1.1. My code to set up my links looked like:

$(document).bind("pageinit", function() {
  onDeviceReady();
});
function onDeviceReady(){
  var root = this;
  cb = window.plugins.childBrowser;
  if (cb != null) {
    $('a[target="_blank"]').click(function(event){
      cb.showWebPage($(this).attr('href'));
      event.preventDefault();
    });
  }
}

注意: pageinit 事件像通常的 $(document).ready()但是对于jQuery Mobile。

Note: The pageinit event is like the usual $(document).ready() but for jQuery Mobile.

链接点击,但不能再关闭后再次。要修复,我在 event.preventDefault();

With that, ChildBrowser opened on the first link click, but then not again after closing it. To fix, I added these two lines after event.preventDefault();:

event.stopImmediatePropagation();
return false;

这对我有用!

这篇关于Phonegap 1.7中的Childbrowser插件只能第一次打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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