简体   繁体   中英

jquery ui dialog - open when page loads if browser is ie

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.

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

<!--[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:

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

You can find more in documentation for jQuery.browser

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