Windows 8下的InAppBrowser不起作用

时间:2015-05-11 13:41:46

标签: cordova windows-8 sencha-touch inappbrowser

我在不同平台下的Cordova项目中工作,例如iOS和Windows 8平板电脑,这个应用程序在IE11或Chrome等浏览器中都有支持,但我在使用InAppBrowser插件时,在W8平板电脑下实现了问题不工作,如果你在不同的按钮“点击”打开附件,这个事件不起作用......有什么问题??!

我有一个班级来管理下一个代码...

openLinkInNewWindow: function (url) {
    var link = Ext.getDom(this.getLinkId()),
        clickevent = document.createEvent('Event'),
        hash = location.hash;

    if (Ext.browser.is.Standalone) {
        localStorage.setItem('lastVisitRouteForLunchApp', hash);
    }
    if (Ext.os.deviceType == "Tablet" && Ext.os.name == "Windows") {
        window.open(url, '_blank', 'location=yes');
    }
    if (Ext.os.deviceType == "Tablet" && Ext.os.name == "iOS") {
        window.open(url, '_blank', 'location=yes');
    } else {
        link.href = url;
        Ext.Function.defer(function () {
            clickevent.initEvent('click', true, false);
            link.dispatchEvent(clickevent);
        }, 500);
    }
}

我做错了什么? (代码基于Sencha Touch Framework)

1 个答案:

答案 0 :(得分:0)

我找到了解决方案,并在index.html中添加了下一个代码

function isPhoneGap() {
    if (navigator.userAgent.match(/(iPhone|iPod|iPad)/)) {
        return true;
    } else {
      return false;
    }
}

function openPage(link) {
    if (isPhoneGap() == true) {
        var ref = window.open(link.href, '_blank', 'location=yes,enableViewPortScale=yes');
        return false;
    } else {
        return true;
    }
}

现在它工作正常,我很开心! : - )

相关问题