<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <title></title>
    <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
    <script>

        function setUnloadConfirm() {
            window.onbeforeunload = function () {
                return "您确定要离开吗?";
            };
            if (typeof window.disableTabClose === 'function') {
                window.disableTabClose.call();
            }
        }

        function cancelUnloadConfirm() {
            window.onbeforeunload = null;
            if (typeof window.enableTabClose === 'function') {
                window.enableTabClose.call();
            }
        }

        var download = function (url) {
            cancelUnloadConfirm();
            $('<form name="ajaxDownLoad" >+
                '</form>')
                .appendTo('body').remove();
            setTimeout(setUnloadConfirm, 100);
        };

        var aaadownload = function () {
            download(document.getElementById("txtUrl").value);
        };
        setUnloadConfirm();
    </script>
</head>
<body>
    <form action="http://localhost:8011/aaa.pdf" method="post">
        <input type="button" value="下载" onclick="aaadownload();" />
        <input type="submit" value="提交" />
        <input id="txtUrl" type="text" value="http://localhost:8011/aaa.pdf" />
    </form>
</body>
</html>

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-08-05
  • 2021-10-16
  • 2018-12-12
  • 2022-01-12
猜你喜欢
  • 2021-08-12
  • 2022-12-23
  • 2021-09-22
  • 2021-11-12
  • 2021-06-26
  • 2022-02-12
  • 2021-07-26
相关资源
相似解决方案