如何在jQuery移动多页面模板结构中显示第二页作为默认页面
How to show the second page as the default page in a jQuery mobile Multi-page template structure?
如何在jQuery移动多页模板结构中显示第二页作为默认页面?
<body>
<div data-role="page" id="foo">
<div data-role="header">
<h1>Foo</h1>
</div>
<div data-role="content">
<p>I'm first in the source order so I'm shown as the page.</p>
</div>
</div>
<div data-role="page" id="home">
<div data-role="header">
<h1>Home</h1>
</div>
<div data-role="content">
<p>I'm the second in the source order so I'm hidden when the page loads. I'm just shown if a link that references my id is beeing clicked.</p>
</div>
</div>
<div data-role="page" id="bar">
<div data-role="header">
<h1>Bar</h1>
</div>
<div data-role="content">
<p>I'm the second in the source order so I'm hidden when the page loads. I'm just shown if a link that references my id is beeing clicked.</p>
</div>
</div>
</body>
示例
工作示例:http://jsfiddle.net/Gajotres/UfDaf/
使用<<h2>代码/h2>这部分将阻止正常的页面加载。不要忘记,在我的例子中,mobileinit 必须在 jQuery Mobile
初始化之前初始化。
$(document).on("mobileinit",function() {
$.mobile.autoInitializePage = false;
});
这部分将开始手动页面初始化:
$(document).ready(function() {
window.location.hash = 'home';
$.mobile.initializePage();
});
虽然我通常建议不要使用文档就绪,但这里我们需要它来启动手动更改。
完整代码示例
In case jsFiddle
down
<!DOCTYPE html>
<html>
<head>
<title>jQM Complex Demo</title>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; minimum-scale=1.0; user-scalable=no; target-densityDpi=device-dpi"/>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.css" />
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script>
$(document).on("mobileinit",function() {
$.mobile.autoInitializePage = false;
});
</script>
<script src="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js"></script>
</head>
<body>
<div data-role="page" id="foo">
<div data-role="header">
<h1>Foo</h1>
</div>
<div data-role="content">
<p>I'm first in the source order so I'm shown as the page.</p>
</div>
</div>
<div data-role="page" id="home">
<div data-role="header">
<h1>Home</h1>
</div>
<div data-role="content">
<p>I'm the second in the source order so I'm hidden when the page loads. I'm just shown if a link that references my id is beeing clicked.</p>
</div>
</div>
<div data-role="page" id="bar">
<div data-role="header">
<h1>Bar</h1>
</div>
<div data-role="content">
<p>I'm the second in the source order so I'm hidden when the page loads. I'm just shown if a link that references my id is beeing clicked.</p>
</div>
</div>
</body>
</html>
Javascript: $(document).ready(function() {
window.location.hash = 'home';
$.mobile.initializePage();
});
我知道这个问题有点老了,但是我偶然发现了一个简单的解决方案:
window.location.href = "_dash.html#page-two";
或者如果你从一个单独的页面导航,你可以做一个链接,把u放到第二页,像这样:
<a href="_dash.html#page-two">link to second page</a>
只需在url末尾添加第二页的页面id
相关文章:
- 用嵌套函数和默认函数定义函数
- 在<页眉>标签
- 使用javascript将动态表从一个html页面打印到另一个html页
- 如何使用skip参数使用angular ui引导进行服务器端分页
- 正在SharePoint 2013母版页中添加JQuery移动文件
- 浮动页脚栏-使用Bootstrap隐藏
- 如何通过引用var Using DataTables来进行分页或排序
- 如何获取不属于我项目的上一页的URL
- 带有默认页面的 JS 后退按钮
- Angular ui.router默认页眉页脚
- 选择列表项分页内的默认选项卡
- 通过聚合物核心页组件指定默认的熨斗控制器路由(内部元素)
- 加载时blockUI,加载ASP.NET WebForm默认页后取消阻止UI
- 如何在jQuery移动多页面模板结构中显示第二页作为默认页面
- HTML
- 覆盖ui-bootstrap的默认分页模板
- javascript退格默认问题..返回一页
- Chrome扩展默认html或404(用于单页应用程序路由)
- 如何运行“加二”;图像幻灯片放映”;在一页上
- 打印HTML时删除默认的浏览器页眉和页脚