JavaScript的使用jQuery Mobile不在Android 2.3及更低的工作 [英] Javascript with Jquery Mobile not working in Android 2.3 and lower
问题描述
我工作的一个应用程序,但它不会给用户的操作任何回应。当您提交表单,你只是得到一个空白页。按钮Anoniem inloggen没有任何工作,无论是在JavaScript创建。这只使用的 Android 2.3的时候发生的或更低。我已经尝试了很多解决方案,但至今没有工作过。即使是已经给定的解决方案将无法工作。
I'm working on an application but it won't give any response on user actions. When you submit the form you just get a empty page. The button Anoniem inloggen don't work either, both are created in javascript. This only happens when using Android 2.3 or lower. I have tried a lot of solutions, but none has worked so far. Even the already given solutions won't work.
链接到应用程序: http://goo.gl/MsZfO
这个应用程序的索引脚本是这样的:
The index script of this app looks like this :
<script type="text/javascript">
$(document).ready(function($) {
checkMail();
$.post('stats.php',
function (data, textStatus) {
$('#stats').empty();
$('#stats').append(data).page();
$('#stats').page('destroy').page();
});
$.post('welcome.php',
function (data, textStatus) {
$('#mail').empty();
$('#mail').append(data).page();
$('#mail').page('destroy').page();
});
function checkMail() {
var item = localStorage.getItem('maillogin');
if (item !== null) {
window.location = '#stats';
}
else{
window.location = '#mail';
}
}
});
</script>
该指数的身体:
<div data-role="page" data-theme="a" id="mail" data-transition="none">
</div>
<div data-role="page" data-theme="a" id="stats" data-transition="none">
</div>
和这里的问题页面(的welcome.php)脚本:
And here's the problem page (welcome.php) script:
$(document).ready(function($) {
$('#mailform').submit(function () {
$.mobile.showPageLoadingMsg();
var email = document.getElementById('email');
var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (!filter.test(email.value)) {
$.mobile.changePage("#mail");
alert('Dit is geen geldig mailadres');
$.mobile.hidePageLoadingMsg();
return false
}
else{
if($('#checkbox').attr('checked')) {
$.post('mailinsert.php',
$('#mailform').serialize())
localStorage.setItem('maillogin', $('#email').val());
$('#inlogmail').empty();
$('#inlogmail').append(localStorage.getItem('maillogin')).trigger('create');
$.post('stats.php',
function (data, textStatus) {
$('#stats').empty();
$('#stats').append(data).page();
$('#stats').page('destroy').page();
$.mobile.changePage("#stats");
$.mobile.hidePageLoadingMsg();
});
}
else{ $.mobile.changePage("#mail");
alert('De voorwaarden zijn niet geaccepteerd');
$.mobile.hidePageLoadingMsg();
return false;
}
}
});
$('#skipright').click(function(){
localStorage.setItem('maillogin', 'anoniem');
$.post('stats.php',
function (data, textStatus) {
$('#stats').empty();
$('#stats').append(data).page();
$('#stats').page('destroy').page();
$.mobile.changePage("#stats");
$.mobile.hidePageLoadingMsg();
});
});
});
和问题页(的welcome.php)正文:
And the problem page (welcome.php) body:
<form id="mailform">
<div data-role="fieldcontain">
<label for="email">E-mail:</label>
<input name="email" id="email" type="text" />
<br />
<div class="ui-grid-b ui-corner-all ui-shadow ui-bar ui-bar-b">
<input type="checkbox" name="checkbox" id="checkbox" data-role="none"/>
<label for="checkbox">Ja, ik accepteer de voorwaarden</label>
</div></br>
<input type="submit" value="Stemmen maar!"/>
</div>
</form>
<h3><a class="skipright" id="skipright">Anoniem inloggen</a></h3>
</div>
因此,在短期的类似。点击的welcome.php的实施的行动,并在Android 2.3或更低.submit不会index.html的工作。我们怎样才能解决这些?
So in short the implemented actions from welcome.php like .click and .submit won't work in index.html on android 2.3 or lower. How can we fix these?
推荐答案
试着改变你下面一行:
window.location = '#stats';
这一个:
window.location.href += '#stats';
更新:结果
如果你已经在位置装一个锚链接(如 #home
),然后执行以下操作:
UPDATE:
If you already have an anchor link loaded in the location (like #home
) then do the following:
window.location.href = window.location.href.substr(0, window.location.href.lastIndexOf('#')) + '#stats';
这篇关于JavaScript的使用jQuery Mobile不在Android 2.3及更低的工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!