Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/475.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript JQmobi-动态切换页面_Javascript_Html_Mobile_Swipe_Jqmobi - Fatal编程技术网

Javascript JQmobi-动态切换页面

Javascript JQmobi-动态切换页面,javascript,html,mobile,swipe,jqmobi,Javascript,Html,Mobile,Swipe,Jqmobi,我这里有一段JQMobi代码。问题是它不会动态切换页面: <div title='Whatever' id="main" class="panel" selected="true" data-tab="navbar_home" data-footer="none"> <div class="swipe_area"> <!-- nothing here, just for swiping to not disturb other

我这里有一段JQMobi代码。问题是它不会动态切换页面:

<div title='Whatever' id="main" class="panel" selected="true" data-tab="navbar_home" data-footer="none">
        <div class="swipe_area">
            <!-- nothing here, just for swiping to not disturb other elements -->
            <- Swipe me ->
        </div>
        <script>
            var init_swipe = function () {
            $(".swipe_area").swipeListener({
                    vthreshold: 30,
                    hthreshold: 80,
                    callBack: function (dir) {
                        if(dir.left) {
                            window.location.href = "#menulink3";
                            alert("go to menulink3");
                        }
                        else if(dir.right) {
                            window.location.href = "#menulink2";
                            alert("go to menulink2");
                        }
                    }
                });
            };
            window.addEventListener("load", init_swipe, false);
        </script>
</div>
<div title='Whatever' id="menulink2" class="panel" selected="true" data-tab="navbar_home" data-footer="none">
    content of menulink2
</div>
<div title='Whatever' id="menulink3" class="panel" selected="true" data-tab="navbar_home" data-footer="none">
    content of menulink3
</div>

var init_swipe=函数(){
$(“.swipe_区域”)。swipeListener({
阈值:30,
hthreshold:80,
回调:函数(dir){
如果(方向左){
window.location.href=“#menulink3”;
警报(“转到菜单3”);
}
else if(右方向){
window.location.href=“#menulink2”;
警报(“转到menulink2”);
}
}
});
};
addEventListener(“加载”,初始滑动,错误);
menulink2的含量
menulink3的含量
url在浏览器中会发生变化,并发出警报(只是为了确保),但在页面中没有切换。此外,正常的a href链接也可以正常工作。我是否需要调用jqmobi函数来刷新它


提前感谢

您不需要更改
窗口。位置
即可导航。查看
$.ui.loadContentDiv
以编程方式进行操作。

您不需要更改
窗口。位置
来导航。查看
$.ui.loadContentDiv
以编程方式进行操作。

嗨,Irvin,我确实找到了。你说得对极了。但是我找不到一个按钮来让你的答案正确。嗨,欧文,我确实找到了。你说得对极了。但是我找不到一个按钮来让你的答案正确