我有以下代码放在我的基于Bootstrap的WordPress主题中,我希望在页面加载时打开而不是点击按钮,并且每个用户在首次访问网站时只加载一次。
代码:
<div class="container">
<div class="row">
<div class="span12">
<a data-toggle="modal" class="btn" href="#loginModal">Log in</a>
<div class="modal hide" id="loginModal">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">✕</button>
<h3>Login to Website</h3>
</div>
<div class="modal-body" style="text-align:center;">
<div class="row-fluid">
<div class="span10 offset1">
<div id="modalTab">
<div class="tab-content">
<div class="tab-pane active" id="login">
<form method="post" action='' name="login_form">
<p><input type="text" class="span12" name="eid" id="email" placeholder="Email"></p>
<p><input type="password" class="span12" name="passwd" placeholder="Password"></p>
<p><button type="submit" class="btn btn-primary">Sign in</button>
<a href="#forgotpassword" data-toggle="tab">Forgot Password?</a>
</p>
</form>
</div>
<div class="tab-pane fade" id="forgotpassword">
<form method="post" action='' name="forgot_password">
<p>Hey this stuff happens, send us your email and we'll reset it for you!</p>
<input type="text" class="span12" name="eid" id="email" placeholder="Email">
<p><button type="submit" class="btn btn-primary">Submit</button>
<a href="#login" data-toggle="tab">Wait, I remember it now!</a>
</p>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
谢谢,
答案 0 :(得分:0)
您可以在就绪功能
中使用以下代码打开模态$('#myModal').modal();
如果你想为每个用户添加,那么你需要在加载时设置cookie。然后检查是否设置了cookie。如果设置然后不加载模态,如果没有设置则加载模态。
Find Cookie reference here这太简单了。您将在给定的URL中找到设置,读取和擦除cookie功能。