这是我的第一个使用
jquery mobile的网站,我遇到外部链接问题.
我会举一个例子.
这是第A页
<!DOCTYPE html > <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>PageA</title> <Meta name="viewport" content="width=device-width,initial-scale=1" /> <Meta name="apple-mobile-web-app-capable" content="yes" /> <Meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" /> <link href="Style/Style.css" rel="stylesheet" type="text/css" /> <link href="http://code.jquery.com/mobile/1.0rc1/jquery.mobile-1.0rc1.min.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="http://code.jquery.com/jquery-1.6.2.min.js"></script> <script type="text/javascript" src="http://code.jquery.com/mobile/1.0rc1/jquery.mobile-1.0rc1.min.js"></script> </head> <body> <!-- Start of first page --> <div data-role="page" id="pageA" data-title="Page A" data-theme="b" data-dom-cache="false"> <div data-role="header" data-theme="b"> <h1>Page A</h1> </div> <!-- /header --> <div data-role="content"> <ul data-role="listview" data-theme="g"> <li><a href="PageB.htm" rel="external">PageB</a></li> </ul> </div> </div>
当我点击链接时,我要去B页(到目前为止,一切正常)
<!DOCTYPE html > <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Pag B</title> <Meta name="viewport" content="width=device-width,initial-scale=1" /> <Meta name="apple-mobile-web-app-capable" content="yes" /> <Meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" /> <link href="Style/Style.css" rel="stylesheet" type="text/css" /> <link href="http://code.jquery.com/mobile/1.0rc1/jquery.mobile-1.0rc1.min.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="http://code.jquery.com/jquery-1.6.2.min.js"></script> <script type="text/javascript" src="http://code.jquery.com/mobile/1.0rc1/jquery.mobile-1.0rc1.min.js"></script> </head> <body> <!-- Start of first page --> <div data-role="page" id="pageB" data-title="Page B" data-theme="b" data-dom-cache="false"> <div data-role="header" data-theme="b"> <h1>Page B</h1> </div> <!-- /header --> <div data-role="content"> <p>I am Page B!!!</p> </div> <!-- /content --> <div data-role="footer" data-theme="c"> <h4>Test</h4> </div> <!-- /footer --> </div>
当我在页面B中时,我按下Android移动设备中的硬件后退按钮并返回到Pag A.
然后我再次按下页面A中的链接.页面B出现但它也加载了页面A,并显示了典型的加载div.
问题是?这为什么会发生?这样做的方式是什么?
我找到了一种方法来解决页面B中的pagebeforehide事件,但我认为这不是这样做的方法.
谢谢!
解决方法
我遇到了类似的问题.我设法将其缩小到与使用硬件后退按钮相关的问题.使用此按钮时,移动浏览器未启动document.ready或pageinit事件.此外,这些事件在按下后退按钮后再次从B页转到A时发射不止一次.
绑定到body元素内的onunload修复了问题.在上面的示例中,将其包含在页面A的body标签中解决了以下问题:
感谢Pumbaa80和Nickolay Is there a cross-browser onload event when clicking the back button?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。