Jump to content

Cookies and pop-ups


whaphansen

Recommended Posts

Hi there

Is there anyone who can help a javascript Noob? And explain what is missing in my javascript code, so the pop-up only is displayed once per. session.
Because right now, it pops up every time I click to a new page. And the idea is that it is should work like the business or consumer popup on dustin.com.

Is my Javascrip code.

 

<!--Modal-->

<!--modalpopup Business eller privat-->
<script>
$(document).ready(function(){
//loads when document is ready

if (document.cookie.indexOf('modal_shown=') >= 0) {
 //do nothing if modal_shown cookie is present
} else {
  $('.modal').modal('show');  //show modal pop up
  document.cookie = 'modal_shown=seen'; //set cookie modal_shown
  //cookie will expire when browser is closed
}

})
</script>

  <script>
$ts.ready(function()
{
    $elm('[data-dismiss="modal"]').onclick = function()
    { 
        $elm('.container').style.display = 'none';
    }
});
</script>

<!--test-->
  <script>
$ts.ready(function()
{
    $elm('[data-dismiss="modal-footer"]').onclick = function()
    { 
        $elm('.container').style.display = 'none';
    }
});
</script>

<!---->

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...