我正在 inAppBrowser CordovaAndroid中打开一个网页。我想在用户下拉该页面时重新加载该页面。我正在使用iScrollView(https://github.com/watusi/jquery-mobile-iscrollview(。
我什至无法拉下打开的网页,也无法触发事件?
我尝试了以下代码,但是由于inAPPbrowser在Web视图中打开,因此在绑定事件时遇到问题。
通过应用程序浏览器在索引中加载网页.js
ENV 是我的网页网址
索引.js
在Ready 上的设备上绑定事件,我也尝试将其与 ref(在应用程序浏览器引用中(绑定,这也不起作用
onDeviceReady: function() {
this.receivedEvent('deviceready');
env = env_variable;
ref = cordova.InAppBrowser.open(env, '_blank','clearcache=no,location=no, clearsessioncache=no,
footer=no,zoom=no' );
new jQuery(function(){
new jQuery(".iscroll-wrapper").bind({
iscroll_onpulldown: onPullDown,
iscroll_onpullup: onPullUp
});
new jQuery( document ).ready(function() {
console.log( "ready!" );
alert('ready');
});
});
索引.html
<body>
<div data-role="content" data-iscroll >
<div class="app">
<div class="iscroll-pulldown">
<span class="iscroll-pull-icon"></span>
<span class="iscroll-pull-label"></span>
</div>
<h1>My Power Grid</h1>
<div id="deviceready" class="blink">
<p class="event listening">Connecting to Device</p>
<p class="event received">Device is Ready</p>
</div>
<div class="iscroll-pullup">
<span class="iscroll-pull-icon"></span>
<span class="iscroll-pull-label"></span>
</div>
</div>
</div>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script>
var jq = jQuery.noConflict();
</script>
<script src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"></script>
<script src="js/iscroll.js" type="text/javascript"></script>
<script src="js/jquery.mobile.iscrollview.js" type="text/javascript"></script>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/index.js"></script>
<script type="text/javascript" src="js/env.js"></script>
</body>
我在控制台中收到的唯一消息是
: D/SystemWebChromeClient: file:///android_asset/www/js/iscroll.js: Line 1070 : 'webkitCancelAnimationFrame' is vendor-specific. Please use the standard 'cancelAnimationFrame' instead.
I/chromium: [INFO:CONSOLE(1070)] "'webkitCancelAnimationFrame' is vendor-specific. Please use the standard 'cancelAnimationFrame' instead.", source: file:///android_asset/www/js/iscroll.js (1070)
当我不加载索引时.js我将jquery代码放在index.html中,然后我能够下拉页面,也可以触发事件。
如何在应用程序浏览器中绑定iscroll?谁能帮忙?
尝试使用 executeScript 方法执行 JS:
var ref = cordova.InAppBrowser.open(env, '_blank','clearcache=no,location=no, clearsessioncache=no,
footer=no,zoom=no');
ref.addEventListener('loadstart', function() {
ref.executeScript({
code:
'new jQuery(function(){
new jQuery(".iscroll-wrapper").bind({
iscroll_onpulldown: onPullDown,
iscroll_onpullup: onPullUp
});
new jQuery( document ).ready(function() {
console.log( "ready!" );
});
});'
});
});