Click here to Skip to main content
15,880,299 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Do anyone know how to combine these 2 javascript together ? which is setTimeout function for modal window and cookie function for modal window . I'm new in javascript don't know how to write these 2 function together , wish someone to help out .I had set "TimerOut" function for modal window after page loaded and display .On the other side , I set cookie for it too ,I just need modal window display in once .Now the TimerOut function was overlapping the cookie function . Thanks in advance ! here my code

Modal window settimerout function :
XML
<script type="text/javascript">
var show = function(){
    $('#myModal').modal('show');
};

$(window).load(function(){
    var timer = window.setTimeout(show,3000);
});
</script>


Modal window with cookie function :

PHP
$(document).ready(function(){
    $('.bs-docs-sidebar').affix({
        offset: {
          top: 10
        }
    })
    if ($.cookie('pop') == null) {
                $('#myModal').modal('show');
                $.cookie('pop', '7');
            }
});

$(function($) {
$('#deleteCookie').click(function() {
        $.cookie('pop', null);
        window.location.reload();
      });
 });
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900