document.location.href ='#位置“;与$ .mobile.changePage('#位置“); [英] document.location.href='#location'; vs. $.mobile.changePage('#location');

查看:189
本文介绍了document.location.href ='#位置“;与$ .mobile.changePage('#位置“);的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这两个redirrections之间的区别是什么?我有一个应用程序,它在Chrome和Android 4正常工作,当我使用,但不能在Android 2.xx的

What is the difference between these two redirrections? I've got an application, which works correctly on chrome and android 4, when I use, but not on android 2.x.x

document.location.href='#location';

但是当我使用

But when I use

$.mobile.changePage('#location');

不正确无论是在铬也不是机器人工作。 Redirrection似乎发生,但之后,它跳到我的应用程序的索引页面。

it does not work correctly neither in chrome nor in android. Redirrection seems to happen, but then immediately after that it jumps to the index page of my application.

推荐答案

$。mobile.changePage 是JQM样式的方法进行导航。也就是说,如果你有AJAX导航启用(它是默认启用),页面您链接到将异步获取并注入到当前页面的DOM。

$.mobile.changePage is jQM style method for navigation. Meaning that if you have AJAX navigation enabled (it's enabled by default), page you linked to will be fetched asynchronously and injected into DOM of current page.

这是通过获取目标页面完成,扫描它的JQM页面(容器元素与数据角色=页面),注入的元素融入当前的DOM和显示器它,而隐藏previous内容。

This is done by fetching target page, scanning it for jQM page (container element with data-role='page'), injecting that element into current DOM and displays it, while hiding previous content.

查看更多详情 jQuery Mobile的文档

确认

  • 您的目标页面有一个jQuery Mobile的页面
  • 目标网页的JQM(使用招或类似工具)
  • 在它存在于当前页面的DOM

您也可以决定禁用AJAX导航(开发移动应用程序时,这是错误的想法)。这是由 ajaxEnabled mobileinit 处理程序设置为false完成。详情查询 JQM配置文档。请确保您的 mobileinit 挂钩执行之前,包括jQuery的,mobile.js在你的页面。

You may also decide to disable AJAX navigation (which is wrong idea when developing mobile applications). This is done by setting ajaxEnabled to false in mobileinit handler. For more details check jQM configuration documentation. Make sure that your mobileinit hook is executed before you include jquery-mobile.js in your page.

这篇关于document.location.href ='#位置“;与$ .mobile.changePage('#位置“);的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆