【问题标题】:Displaying modal dialog only once, then not displaying again until user has cleared cache or cookies仅显示一次模式对话框,然后在用户清除缓存或 cookie 之前不再显示
【发布时间】:2014-02-19 02:08:00
【问题描述】:

仅显示一次模式对话框,然后在用户清除缓存或 cookie 之前不会再次显示。

我想在用户访问我的网站时显示一个模态对话框,但只显示一次。如果用户关闭或使用它,我希望很长时间不会再次显示它。

我的 jsFiddle 在: http://jsfiddle.net/B84tq/

我的html是:

  <!-- Button to trigger modal -->
  <a href="#myModal" role="button" class="btn" data-toggle="modal">Launch demo modal</a>

  <!-- Modal -->
  <div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-header">
      <button type="button" class="close" data-dismiss="modal" aria-hidden="true">X</button>
      <h3 id="myModalLabel">Email Deals</h3>
    </div>
    <div class="modal-body">
        <p>Sign up for email-only specials and news updates. We will not sell or rent your email address.</p>
        <p>Sign up now!</p>
          <form class="form-horizontal" method="post" action="http://www.gliq.com/cgi-bin/subunsub">
          <div class="input-prepend">
          <input type="hidden" name="acctname" value="amleo"/>
          <input type="hidden" name="action" value="subscribe"/>
          <input type="hidden" name="url" value="http://www.amleo.com/subscribe-successful/a/47/"/>
          <input type="text" placeholder="Your email address" id="inputIcon" class="input-xlarge" name="email">
          <input value="SUBSCRIBE" class="btn btn-orange" type="submit">
          </div>
          </form>
        <p><a href=" [[DMI:Control name='FriendlyUrlArticleSiteMap' dmisource='Core.GetContentByNumber("3")']][[/DMI:Control]]">Privacy Policy</a>.</p>
    </div>
  </div>

【问题讨论】:

  • 那么你的问题是如何使用cookie???怎么样搜索一下,网上有上千个关于如何使用cookies的示例代码...

标签: javascript jquery twitter-bootstrap caching cookies


【解决方案1】:

使用 cookie。

你可以google如何在js中处理cookie。

例如。在伪代码中

if (document.cookies['testvalX']!=1)
{
   //display modal
   document.cookies[] = 'testvalX=1';
}

【讨论】:

  • 最现代的 cookie 处理方式是什么?我看到了 2003 年和 2008 年的大量文章。此外,如果我不知道实际代码是什么,伪代码也无济于事:(
猜你喜欢
  • 1970-01-01
  • 2014-04-04
  • 2021-03-22
  • 1970-01-01
  • 2011-07-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多