0

Live site- http://www.uposonghar.com/test/test_popup.html

I add JavaScript cookie with that popup so if anyone click on "Click Here if don't want to see this Again!" button then cookie will be stored, if cookie is stored then popup will not appear for him/her.

Once i click on that button cookie stored successfully, popup(id-myModal) disappear but popup bg/overlay(id- reveal-modal-bg) appears. i add that code but that doesn't work-

if(getCookie('abc')=="def" && document.getElementById('myModal'))
   document.getElementById('myModal').style.display="none";
   document.getElementById('reveal-modal-bg').style.display="none";

There is a css on js page, maybe that overwrite my display:none as display:block- http://www.uposonghar.com/test/jquery.reveal.js

Code of js page-

if(options.animation == "none") {
                    modal.css({'visibility' : 'visible', 'top':$(document).scrollTop()+topMeasure});
                    modalBG.css({"display":"block"});   
                    unlockModal()               
                }

Full code-

<script type="text/javascript">

        function setCookie(c_name,value,exdays)
        {
        var exdate=new Date();
        exdate.setDate(exdate.getDate() + exdays);
        var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
        document.cookie=c_name + "=" + c_value + ";path=/";
        }

        function getCookie(c_name)
        {
        var c_value = document.cookie;
        var c_start = c_value.indexOf(" " + c_name + "=");
        if (c_start == -1)
          {
          c_start = c_value.indexOf(c_name + "=");
          }
        if (c_start == -1)
          {
          c_value = null;
          }
        else
          {
          c_start = c_value.indexOf("=", c_start) + 1;
          var c_end = c_value.indexOf(";", c_start);
          if (c_end == -1)
          {
        c_end = c_value.length;
        }
        c_value = unescape(c_value.substring(c_start,c_end));
        }
        return c_value;
        }


        if(getCookie('abc')=="def" && document.getElementById('myModal'))
        document.getElementById('myModal').style.display="none";
        document.getElementById('reveal-modal-bg').style.display="none";
</script>
1
  • Can you try my answer? I have just updated it. Commented Feb 21, 2014 at 8:49

1 Answer 1

1

Can you change the javascript in jquery.reveal.js to

                if(options.animation == "fadeAndPop" && getCookie('abc')!="def") {
                    modal.css({'top': $(document).scrollTop()-topOffset, 'opacity' : 0, 'visibility' : 'visible'});
                    modalBG.fadeIn(options.animationspeed/2);
                    modal.delay(options.animationspeed/2).animate({
                        "top": $(document).scrollTop()+topMeasure + 'px',
                        "opacity" : 1
                    }, options.animationspeed,unlockModal());                   
                }
                if(options.animation == "fade" && getCookie('abc')!="def") {
                    modal.css({'opacity' : 0, 'visibility' : 'visible', 'top': $(document).scrollTop()+topMeasure});
                    modalBG.fadeIn(options.animationspeed/2);
                    modal.delay(options.animationspeed/2).animate({
                        "opacity" : 1
                    }, options.animationspeed,unlockModal());                   
                } 
                if(options.animation == "none" && getCookie('abc')!="def" ) {
                            modal.css({'visibility' : 'visible', 'top':$(document).scrollTop()+topMeasure});
                            modalBG.css({"display":"block"});   
                            unlockModal()               
                }
Sign up to request clarification or add additional context in comments.

3 Comments

A direct style setting on an object overrides a CSS stylesheet, no matter the load order of the style sheet.
The javascript in the page is making the direct style to display block. That is why we need to make it 'none' in onLoad.
Please add it to all cases. I am not sure whether your options.animation is "none" or "fade"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.