jquery ui dialog - open when page loads if browser is ie
I have a jQuery UI di开发者_运维百科alogue 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
精彩评论