jquery ui对话框 - 如果浏览器是ie,则在页面加载时打开

时间:2022-12-01 16:17:24

I have a jQuery UI dialogue but need it to open as soon as the page is loaded if the browser is ie (Internet Explorer). I have made the dialogue, but cannot seem to find anywhere in the API Documentation to open a dialogue on load.

我有一个jQuery UI对话框,但是如果浏览器是ie(Internet Explorer),则需要在加载页面时立即打开它。我已经进行了对话,但似乎无法在API文档中的任何地方找到加载对话框。

2 个解决方案

#1


1  

Just attach a normal $(window).load() handler but wrap it in a conditional comment:

只需附加一个普通的$(window).load()处理程序,但将其包装在条件注释中:

<!--[if IE]>
    <div id="ie-dialog">...</div>
    <script type="text/javascript">
        $(window).load(function() {
            $('#ie-dialog').dialog();
        });
    </script>
<![endif]-->

You could also wait until the DOM is ready if you need it:

如果需要,您也可以等到DOM准备就绪:

<!--[if IE]>
    <div id="ie-dialog">...</div>
    <script type="text/javascript">
        $(document).ready(function() {
            $('#ie-dialog').dialog();
        });
    </script>
<![endif]-->

#2


0  

$(function() {
    if(jQuery.browser.msie) {
        $("#dialog").dialog();
    }
});

You can find more in documentation for jQuery.browser

您可以在jQuery.browser的文档中找到更多信息

#1


1  

Just attach a normal $(window).load() handler but wrap it in a conditional comment:

只需附加一个普通的$(window).load()处理程序,但将其包装在条件注释中:

<!--[if IE]>
    <div id="ie-dialog">...</div>
    <script type="text/javascript">
        $(window).load(function() {
            $('#ie-dialog').dialog();
        });
    </script>
<![endif]-->

You could also wait until the DOM is ready if you need it:

如果需要,您也可以等到DOM准备就绪:

<!--[if IE]>
    <div id="ie-dialog">...</div>
    <script type="text/javascript">
        $(document).ready(function() {
            $('#ie-dialog').dialog();
        });
    </script>
<![endif]-->

#2


0  

$(function() {
    if(jQuery.browser.msie) {
        $("#dialog").dialog();
    }
});

You can find more in documentation for jQuery.browser

您可以在jQuery.browser的文档中找到更多信息