0

I ask for your help to insert two destination links in the buttons inside a confirmation popup plugin. There are two buttons in the plugin A and B I wish there was a href link for both. I hope you can help me.

Place the code:

$( "#demo2" ).on( "click", function() {
  $cw({


    title: '✓',
    content: 'testo',
    theme: 'light',
    okay: {
    text: 'BOTTONE A',
    action: function() { console.log('Clicked okay button'); }
},
cancel: {
     text: 'BOTTONE B',
     action: function() { console.log('Clicked cancel button'); }
}


});
});

if ( typeof jQuery === 'undefined' ) { throw new Error('jQuery is not loaded.'); }

(function($, window){

$.confirm = function( opt ) {


    $('<div/>', { class: 'cw-wrapper ' + opt['theme'] || 'dark' })
        .css({ left: ($(window).width() - 460) / 2 + 'px' })
        .append($('<div/>', { class: 'cw-header', text: opt['title'] || '' }))
        .append($('<div/>', { class: 'cw-content', text: opt['content'] || '' }))
        .append($('<div/>', { class: 'cw-button blue', text: opt['okay']['text'] || 'Yes' }).click(function() {
            $('#cw-screencover').click(); (typeof opt['okay']['action'] === 'function' ? opt['okay']['action'] : function(){})(); }))
        .append($('<div/>', { class: 'cw-button', text: opt['cancel']['text'] || 'No' }).click(function() {
            $('#cw-screencover').click(); (typeof opt['cancel']['action'] === 'function' ? opt['cancel']['action'] : function(){})(); }))
        .animate({ top: '70px', opacity: '1.0' }, 900)
        .appendTo( $('body')
            .append($('<div/>', { id: 'cw-screencover' })
            .animate({ opacity: '1.0' }, 900)
            .click(function() {
                $('.cw-wrapper').animate({ top: '-300px', opacity: '0.0' }, 900, function() { $(this).remove(); });
                $(this).animate({ opacity: '0.0' }, 900, function() { $(this).remove(); });
            }))
        );

}


window.$cw = $.confirm;

})(jQuery, window);

displacedtexan
  • 976
  • 8
  • 17
mpower
  • 21
  • 2
  • Where it says `console.log('Clicked okay button');`, simply add something like `location = "https://google.com";`: https://jsfiddle.net/khrismuc/odaq6b4m/ (note that the plugin code or the fact that you're using it are mostly irrelevant, all you're asking is "how do I navigate elsewhere using Javascript?") –  Feb 08 '20 at 10:59
  • 1
    Does this answer your question? [How do I redirect to another webpage?](https://stackoverflow.com/questions/503093/how-do-i-redirect-to-another-webpage) –  Feb 08 '20 at 12:05
  • Please rather add jQuery tag, because there is no true JavaScript there... – Martin Melichar Feb 08 '20 at 13:08

0 Answers0