我正在尝试显示一个 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>';
}
?>