我试图在页面加载时检查会话,但当我的页面加载时,它首先调用预加载器函数。我想在执行jquery预加载器函数之前检查会话。
预加载程序函数的代码:
$(window).bind("load", function () {
$('#work-in-progress').fadeOut(100);
});只有当会话为false时,我才希望执行预加载程序函数。例如,在下面的代码中,如果spl为false,那么我只想执行预加载器函数,否则我不想执行它。
用于检查会话的代码:
var spl=('<?php echo $_SESSION['splash'] ?>');
if(!spl==true)
{
}
else
{
}发布于 2014-06-18 14:46:25
在脚本标记中,如果PHP $_SESSION['splash']为FALSE,则编写jQuery .bind函数:
<?php if ( !$_SESSION['splash'] ) { ?>
$(window).bind("load", function () {
$('#work-in-progress').fadeOut(100);
});
<? } ?>发布于 2014-06-18 14:39:55
为什么不像这样:
<? if ($_SESSION['splash']): ?>
<script>
$(function() {
// do work
})
</script>
<? endif; ?>???
而且,if(!spl==true)非常令人困惑。你认为spl会成为Boolean,对吗?如果是spl = false,那么if statement会读if false is not false equal to true,也就是if (true == true)
https://stackoverflow.com/questions/24288388
复制相似问题