[英]Displaying a div automatically on page load
我正在嘗試顯示一個CSS模式框,如果用戶在頁面加載時在其收件箱中有郵件,則該框應為用戶彈出。 到目前為止,我對鏈接<a href="#" id="mail_modal"></a>
,但是我不確定如何使其在頁面加載時自動顯示。 這是我的代碼:
<?php
if ($items > 0)
{
echo '<strong><font color="yellow">You have new unread mail</font></strong>';
?>
<script type="text/javascript">
$(document).ready(function() {
$('#button_modal').click(function(e) {
$('#modal').reveal({
animation: 'fadeAndPop',
animationspeed: 400,
closeonbackgroundclick: true,
dismissmodalclass: 'close'
});
return false;
});
});
</script>
<div id="modal">
<div id="mail-form">
<h1>New Mail</h1>
<fieldset>
<form name="loginform" action="<?php echo url('/Mail');?>">
<p>You have new unread mail in your inbox. Press 'Mail' button to access your inbox.</p>
<input type="hidden" name="redir" value="<?php echo url('/Mail'); ?>" />
<input type="hidden" name="action" value="mail" />
<input type="submit" name="submit" value="Mail" />
</form>
</fieldset>
</div> <!-- end login-form -->
</div>
<?php
}
else
{
echo '<i>You have no new mail</i>';
}
?>
<script type="text/javascript">
$(document).ready(function() {
$('#button_modal').click(function(e) {
$('#modal').reveal({
animation: 'fadeAndPop',
animationspeed: 400,
closeonbackgroundclick: true,
dismissmodalclass: 'close'
});
return false;
});
// and here we show popup automatically, if a user has new letters.
<?php if ($items > 0) echo "$('#button_modal').trigger('click');"; ?>
});
</script>
$(document).ready(function() {
if(/* check if has mail */ === true) {
$('#modal').reveal({
animation: 'fadeAndPop',
animationspeed: 400,
closeonbackgroundclick: true,
dismissmodalclass: 'close'
});
}
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.