window.location会无法正常工作 [英] window.location not work properly
问题描述
大家好,我来自一个HTML页面导航到另一个:
Hi all I am navigating from one html page to another as:
window.location = "test.html";
在test.html的我有标题为:
In test.html I have header as:
<script type="application/javascript">
function redirect()
{
alert("inside redirect:");
//window.location = url;
//history.back();
history.go(-1);
return false;
}
</script>
<div data-role="navbar">
<ul>
<li> <a href="#" data-theme="b" onclick="history.back(); return false;">Go Back</a></li>
<li> <a onclick="redirect()" data-icon="back" data-iconpos="notext" data-direction="reverse" class="ui-btn-left jqm-home">Back1</a></li>
</ul>
</div>
但在这里都后退按钮(返回和Back1)不工作。如果我使用 $。mobile.changePage('的test.html')
在页面之间导航然后返回两个按键的工作。他们为什么不与windows.location?
But here both back buttons (Go Back and Back1) are not working. If I use $.mobile.changePage('test.html')
to navigate between pages then both Back buttons work. Why they are not with windows.location?
我要开发这个应用程序为B级浏览器,不支持AJAX。因此,我不能使用 $。mobile.changePage('的test.html')
。
I want to develop this application for B-Grade browser which are not support ajax. Therefore I cant use $.mobile.changePage('test.html')
.
任何帮助将AP preciated。谢谢你。
Any help will be appreciated. Thanks.
推荐答案
本黑莓OS 5 的浏览器有很多的问题。起初我还试图做你现在正在做什么。但后来我想,所以你将不得不考虑一些其他的办法,这是更好。这是我如何解决它。
This Blackberry OS 5 browser has lots of issue. Initially i also tried to do what you are doing right now. But later i think so you will have to think of some other approach which is better. Here is how i solved it
首先添加这些行加载这样的jQuery的移动脚本之前
First of all add these lines before loading the jquery-mobile script like this
<script type="text/javascript">
$(document).bind("mobileinit", function() {
$.support.cors = true;
$.mobile.allowCrossDomainPages = true;
});
</script>
然后我用在单一的HTML概念。在这个概念,我不得不载入我的剧本只有一次,我可以利用的jQuery移动的 changePage
。当我有很多的HTML页面,然后我必须等待几秒钟加载和脚本卸载发生。避免这种情况,其unnecessarry。
Then i used the Single Html concept. In this concept i had to load my script just once and i could make use of jquery-mobile's changePage
. When i had many html pages then i has to wait for some seconds as loading and unloading of scripts took place. Avoid that, Its unnecessarry.
与在相同的HTML像这样的所有页
Have all the pages with in the same Html like this
<div data-role="page" id="page1">
<div data-role="page" id="page2">
.
.
.
在那之后,你可以轻松地做一个 changePage
像这样
$.mobile.changePage("#page1", {
transition : "slide"
});
我希望你采取正确的方法。
I hope you take the right approach.
这篇关于window.location会无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!