我正在不同平台(例如iOS和Windows 8平板电脑)下的Cordova项目中工作,该应用程序在IE11或Chrome等浏览器中均受支持,但是在W8平板电脑下InAppBrowser插件的实现存在问题工作,并且如果您在不同的按钮中“轻按”以打开附件,则此事件不起作用...是什么问题?!
我有一个班用下一个代码来管理这个问题...
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)
我找到了在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;
}
}
现在它可以正常工作了,我真高兴!!!:-)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句