简体   繁体   中英

Internet Explorer/Edge detector not displaying JQuery dialog

I'm attempting to make a warning for when users visit my site while using either Internet Explorer or Edge, but the code I have simply displays nothing.

The IE/Edge Detector:

    var isIE = /*@cc_on!@*/ false || !!document.documentMode,
    isEdge = !isIE && !!window.StyleMedia;
    if (isIE || isEdge) {
        // Do stuff here
    }

My HTML:

<body>
    <!-- IE Alert -->
    <div id="unsupported-browser" title="Browser Not Supported" style="display:none;text-align:center;">
        <p>
            Uh Oh! Your browser is not supported!
            Downloading a newer browser is recommended for safety and security!
            Download one of the following browsers for an optimal experience!
            <a href="https://www.mozilla.org/en-US/firefox/new/" target="_blank">Mozilla Firefox</a>
            <a href="https://www.google.com/chrome/index.html" target="_blank">Google Chrome</a>
        </p>
    </div>
</body>

My JQuery (With IE/Edge detector):

$(document).ready(function () {
    $('#unsupported-browser').dialog({
        autoOpen: false,
        width: 600,
        buttons: {
            "Ok": function () {
                $(this).dialog("close");
            },
            "Cancel": function () {
                $(this).dialog("close");
            }
        }
    });
    // Detect Internet Explorer/Edge
    var isIE = /*@cc_on!@*/ false || !!document.documentMode,
    isEdge = !isIE && !!window.StyleMedia;
    if (isIE || isEdge) {
        $(function () {
            $('#unsupported-browser').dialog('open');
            return false;
        });
    }
});

I believe the problem is somewhere in the dialog, as when I use alert(); inside the detector, the alert displays just fine. removing display:none; inside the div's style also has no effect.

对于遇到此问题的任何人,您还必须使用<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>导入JQuery UI您的html文件

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM