在页面加载时使用 SweetAlert2 作为弹出窗口

Using SweetAlert2 as popup on page load

我正在尝试在页面加载完成后将 SweetAlert2 用作 "popup box"。 "popup box" 叠加层下方是正常内容。

我怎样才能做到这一点?

参考:

`http://codepen.io/html5andblog/pen/jPzPWj` (this is good but it doesn't onload and redirect)

这是你的作业 ;) [JSFIDDLE]

swal({
  html: 
    '<a href="http://example1.com" id="link1" target="_blank">link 1</a><br>' + 
    '<a href="http://example2.com" id="link2" target="_blank">link 2</a>',
  confirmButtonText: 'Continue >',
  allowOutsideClick: false,
  allowEscapeKey: false
});

// disable "Continue >" button on load
swal.disableButtons();

// handle clicks and enable "Continue >" button when all links are clicked
var clickedLinks = [];
$('body').on('click', '.swal2-modal a', function(e) {
  var link = e.target;
  if (clickedLinks.indexOf(link) === -1) {
    clickedLinks.push(link);
  }
  // when all links are clicked enable "Continue >" button
  if (clickedLinks.length === $('.swal2-modal a').size()) {
    swal.enableButtons();
  }
});