想要在jQuery mobile首次加载时显示对话框消息

N R*_*ing 3 javascript jquery html5 css3 jquery-mobile

在jQuery mobile中,我想在index.html首次加载此页面时在我的主页()中显示一条对话框消息.但是,如果用户导航到我的网站的不同页面并回到我的网站index.html,我不想显示对话框.

我正在考虑使用pageshowpagebeforeshow方法和检查prevPage对象.还有其他好办法吗?

Gaj*_*res 5

使用pageinit事件,它只会触发一次.这可不容易.

jsFiddle示例:http://jsfiddle.net/Gajotres/e9RcT/

$(document).on('pageinit', '#index', function(){       
    alert('This event will trigger only once!');
});
Run Code Online (Sandbox Code Playgroud)

要测试它,请转到第二页然后返回.