ページが読み込まれるたびに jQuery モバイル ダイアログが開きます。Cookie が一度だけ開かれ、二度と開かないように設定されていても、更新のたびに開き続けます。トリガーなしでロードする理由がわかりませんか?どんな助けでも大歓迎です。
ジャバスクリプト
function openDialog() {
var interval = setInterval(function(){
$.mobile.changePage('#dialog');
clearInterval(interval);
},1);
}
$(function() {
if ($.cookie('dialog_shown') == null) {
$.cookie('dialog_shown', 'yes', { expires: 7, path: '/' });
$(document).on('pageshow', '#index', function(){
openDialog();
});
}
});
HTML
<body>
<div data-role="dialog">
<div data-role="header" data-theme="d">
<h1>Custom Dialog</h1>
</div>
<div data-role="content">
<h1>Customize the HTML. Have any content you want in here.</h1>
<p>This is a regular page, styled as a dialog. To create a dialog, just link to a normal page and include a transition and <code>data-rel="dialog"</code> attribute.</p>
<a href="#index" data-role="button" data-theme="b">Button Style</a>
<a href="#index" data-role="button" data-theme="c">Cancel</a>
</div>
</div>
<div data-role="page" id="index">
</div>
</body>