5

This is my javascript function to open a jquery dialog.

   ('#dialog').append(iframe).appendTo("body").dialog({
          autoOpen: false,
          modal: true,
          resizable: false,
          show: 'slide',        
          width: 800,       
          height: 700,        
         close: function() {           
    }   
});             
$('#dialog_click').click("callback",function() {            
   $('#dialog').dialog('open');                 
   return false;
}); 

How can I hide the part show: 'slide, from IE ?

3
  • window.navigator.userAgent Commented Apr 18, 2013 at 11:45
  • 2
    Your question seems like a second-generation question. For example, the real problem is that you are having trouble with slide in IE, which is why you are asking to remove it in IE. You might be able to solve the original problem if you ask. Commented Apr 18, 2013 at 11:47
  • Are you sure you want to do this? Is this because of a particular problem in older versions of IE? What versions are you testing? Have you tried it in IE9 and IE10? They're actually pretty good browsers (especially IE10). Commented Apr 18, 2013 at 12:53

6 Answers 6

2
var options = {
          autoOpen: false,
          modal: true,
          resizable: false,       
          width: 800,       
          height: 700,        
         close: function() {           
    }   
};
if ( ! $.browser.msie){
  options ['show'] = 'slide';
}

$('#dialog').append(iframe).appendTo("body").dialog(options);  
Sign up to request clarification or add additional context in comments.

2 Comments

I'm glad that i could help.
beware: the $.browser feature in jQuery is deprecated, and has been removed entirely from the more recent versions. It is not recommended. (in fact, browser detection in general is not recommended for most use cases)
2

try this

if ( ! $.browser.msie){
  $( "#dialog" ).dialog( "option", "show", "slide" )
} 

1 Comment

beware: the $.browser feature in jQuery is deprecated, and has been removed entirely from the more recent versions. It is not recommended. (in fact, browser detection in general is not recommended for most use cases)
2

jquery has removed support for jQuery.browser.msie from version >= 1.9

so

var opts = {
    autoOpen : false,
    modal : true,
    resizable : false,
    show : 'slide',
    width : 800,
    height : 700,
    close : function() {
    }
};
if (!/msie/.test(window.navigator.userAgent)) {
    opts.show = 'slide';
}

('#dialog').append(iframe).appendTo("body").dialog(opts);
$('#dialog_click').click("callback", function() {
    $('#dialog').dialog('open');
    return false;
});

Comments

2
$('#dialog').append(iframe).appendTo("body").dialog({
          autoOpen: false,
          modal: true,
          resizable: false,       
          width: 800,       
          height: 700,        
         close: function() {           
    } 
});

if(!$.browser.msie) {
     $( "#dialog" ).dialog( "option", "show", "slide" );
}

2 Comments

I tried this but in my case it is not working. The dialog is not opening when I added this. Is any other problem with the code
beware: the $.browser feature in jQuery is deprecated, and has been removed entirely from the more recent versions. It is not recommended. (in fact, browser detection in general is not recommended for most use cases)
2

There are several workarounds for this (conditional comments for the whole script, altering the property later, etc) but noone has posted a solution that does EXACTLY what you asked: excluding a portion of javascript only in IE.

Then take a look at this:

   ('#dialog').append(iframe).appendTo("body").dialog({
          autoOpen: false,
          modal: true,
          resizable: false,

        /*@cc_on @*/
        /*@if (true)

        @else @*/
          show: 'slide',        
        /*@end @*/

          width: 800,       
          height: 700,        
         close: function() {           
    }   
});             
$('#dialog_click').click("callback",function() {            
   $('#dialog').dialog('open');                 
   return false;
}); 

IE won't include show: 'slide',, while non-IE browsers won't read the Conditional Compilation Statements , so the condition will fall in the (not-commented) else part.

Read more on Conditional Compilation Statements

Comments

0

There is several thing you can do.

First there are conditional comments , ie

<!--[if !IE ]>
    <script>
       $('#dialog').append(iframe).appendTo("body").dialog({
         autoOpen: false,
         modal: true,
         resizable: false,
         show: 'slide',        
         width: 800,       
         height: 700,        
         close: function() {           
         }   
       });             
       $('#dialog_click').click("callback",function() {            
         $('#dialog').dialog('open');                 
         return false; 
       }); 
    </script>
<![endif]-->

Or you can check jquery browser variable , as other guys are pointing.

Also if you are going this way, and you really want to target old version of IE you can use some functions specific to it ( like attachEvent )

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.