Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1/themes/base/jquery-ui.css" rel="stylesheet" type="text/css" />
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
   
<div id="dialog-confirm" title="Confirm?">What would you like to do?
  <p><span class="ui-icon ui-icon-alert" style="float: left; margin: 0 7px 20px 0;"></span>You will be redirected to google.com?</p>
</div>
  <a href="http://www.google.com" id="linkButton">LINK</a>
  
 
</body>
</html>
 
  $(function() {
    var $dialog = $( '#dialog-confirm' );
    var $button = $('#linkButton');
    var link = '';
    
    // init dialog
    
    $dialog.dialog({
      resizable: false,
      height:340,
      modal: true,
      autoOpen: false,
      buttons: {
        Ok: function() {
          doSomething(); // reference your function here
          $( this ).dialog( "close" );
        },
        Cancel: function() {
          $( this ).dialog( "close" );
        }
      }
    });
    
    // bind event
    
    $button.on('click', function(e){
      e.preventDefault();
      link = $(this).attr('href');
      $dialog.dialog('open');
    });
    
    function doSomething(){
      window.location = link;
    }
    
  });
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers