3
$(function() {
    $('#yes a').click(function() {
        $.cookie('AutoPlayTrue', '1', {
            expires: 999
        });
        $('.disableAutoPlay').hide('slow');
        $.cookie('ccss_remembered_style', null);
        $.cookie('AutoPlayFalse', null);
    });
    $('#ccss-no a').click(function() {
        $.cookie('AutoPlayFalse', '1', {
            expires: 999
        });
        $('.disableAutoPlay').hide('slow');
        $.cookie('AutoPlayTrue', null);
    });
    if ($.cookie('AutoPlayFalse') === null) {
        $('.disableAutoPlay').show();
    }
    else {
        $('.disableAutoPlay').hide();
    }

    if ($.cookie('AutoPlayTrue') === null) {
        $('.disableAutoPlay').show();
    }
    else {
        $('.disableAutoPlay').hide();
    }
});

I have a pop up box with the HTML:

<li class="widget ccss" id="ccss-widget-3"><h2 class="widgettitle">Should HipHop97.com Automatically Start Playing Music?</h2>
    <ul id="ccss-list">

        <li id="ccss-no"><a href="http://hiphop97.com/wp-content/themes/hiphop/noAutoPlayCSS.css">No</a></li><li id="yes"><a href="#">Yes</a></li>
    </ul>

</li>

I need when the 'yes' button is selected just act as a 'close' and with cookies 'don't show me again' and the 'no' button I've already got the style sheet and stuff code worked out I just need it to not display the box again with cookies. (The element is in the theme, just marked as display:none; it's at the top of the main container.)

I tried this, it's a good concept I suppose, it just doesn't work:

<script type="text/javascript">
jQuery(document).ready(function($) {
    if ($.cookie('AutoPlayFalse')) {
        $('.displayAutoPlay').css('display','none !important');
    }
    if ($.cookie('AutoPlayTrue')) {
        $('.displayAutoPlay').css('display','none !important');
    }
});
</script>
1
  • I would recommend you do not use auto play this would drive people mad trying to find out where the music [sound] coming from, and when they do, they will never visit your website or simply close the window down, but it is up to you. People are not lazy a click of a button to play something it is user friendly.
    – Val
    May 17, 2011 at 9:00

1 Answer 1

0
if(!$.cookie('autoplay')){
   //display box
}else{
   $.cookie('autoplay',1);
}

I dont understand why do you over complicate it as much :)

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.