【发布时间】:2013-02-26 18:30:31
【问题描述】:
我让 javascript 在有人登陆我网站的任何/每个页面上打开一个对话框(只是一些文本,没有其他内容)(是的,我知道它是 javascript 风格的混合体 - 仍在处理这个问题):
$(document).bind("pageinit", function(){
if( getCookieValue('instructionseen') == false)
{
$.mobile.changePage("/php/instructions_alert.php");
document.cookie ="instructionseen=yes; path=/;";
}
});
脚本设置了一个 cookie,以便用户只看到一次对话框。所以这个想法是你来到这个网站,得到一个包含一些指令的对话框,关闭它并继续。
Chrome v24 中的问题(我担心它可能会出现在我无法测试的移动浏览器中)是关闭对话框会使我回到历史记录中的 2 页,所以我返回到带有链接的页面我点击进入我的网站。
例如,假设我的网站是 MS,它是否通过 RS(引荐网站)链接到
Desired: RS > click to MS > Dialog opens > close it > MS in view
On Chrome: RS > click to MS > Dialog opens > close it > back to RS
使用 JQM 提供的 X 或我提供的关闭按钮会发生这种情况:
<a href='#' onclick='$(".ui-dialog").dialog("close");' data-role='button' data-theme='c'>Close</a>
对话来源:
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='utf-8'>
<meta http-equiv='X-UA-Compatible' content='IE=edge,chrome=1'>
<title>title..</title>
<link rel='stylesheet' href='/design/mobile_style.css'>
<link rel='stylesheet' href='http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css' />
<script src='//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js'></script>
<script src='/js/main_and_JQM_init.min.js'></script>
<script src='http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js'></script>
</head>
<body>
<div data-role='dialog' id='instructions_alert_div' data-overlay-theme='b'>
<div data-role='header' data-theme='d'>
<h1>Important!</h1>
</div>
<div data-role='content' data-theme='c'>
content, just text...
<a href='#' onclick='$(".ui-dialog").dialog("close");' data-role='button' data-theme='c'>Close</a>
</div>
</div>
</body>
</html>
谢谢
【问题讨论】:
-
忘了说,这是JQM 1.2 final
-
你能张贴你的对话框的标记吗?
-
@Omar - 对话已发布。你在一两周前帮助我解决了一个类似的问题,我在对话方面不太走运!
-
我正在研究一种替代方法,使用弹出窗口而不是对话框,到目前为止它看起来很有希望 - 以防万一有人花时间在这上面。
-
它返回到“R5”页面,因为对话框是由该页面生成的。它应该由“MS”页面生成。因此,试试这个。
$("#MS").bind("pageinit", function()和对话框中的data-rel="back"。它应该回到“MS”页面。
标签: jquery jquery-mobile mobile