admin管理员组

文章数量:1420095

I was wondering if I can make a button or a div tag only visible/invisible when the user is browsing with IE. I want to achieve that because I have Microsoft JScript runtime error: Access is denied. in IE when the user clicks on a button which triggers hidden asp fileupload control.

EDIT: I have asp button :

<asp:LinkButton ID="btnSavePhoto" runat="server"></asp:LinkButton>

and file upload control with class="hidden" (dysplay: none;):

<asp:FileUpload ID="uploadPhotoDialog" class="hidden" runat="server"/>

The idea is: when the user is browsing with IE - make fileupload visible and link button hidden.

I was wondering if I can make a button or a div tag only visible/invisible when the user is browsing with IE. I want to achieve that because I have Microsoft JScript runtime error: Access is denied. in IE when the user clicks on a button which triggers hidden asp fileupload control.

EDIT: I have asp button :

<asp:LinkButton ID="btnSavePhoto" runat="server"></asp:LinkButton>

and file upload control with class="hidden" (dysplay: none;):

<asp:FileUpload ID="uploadPhotoDialog" class="hidden" runat="server"/>

The idea is: when the user is browsing with IE - make fileupload visible and link button hidden.

Share Improve this question edited Jul 20, 2012 at 8:13 Anton Belev asked Jul 20, 2012 at 7:55 Anton BelevAnton Belev 13.7k23 gold badges74 silver badges115 bronze badges 1
  • Please learn how to accept answers ... if you have no idea what I'm talking about click here - This is your 3rd Question and you have not yet accepted an answer for any of them ... – Manse Commented Jul 20, 2012 at 8:09
Add a ment  | 

3 Answers 3

Reset to default 7

Use conditional ments :

<!--[if IE]>
<div></div> // this is IE
<![endif]-->

or if not IE

<!--[if !IE]> -->
<div></div> // this is NOT IE
<!-- <![endif]-->

Documentation here

Update

Using your ASP markup do the following :

<!--[if !IE]> -->
    <asp:LinkButton ID="btnSavePhoto" runat="server"></asp:LinkButton>
<!-- <![endif]-->
<!--[if IE]>
    <asp:FileUpload ID="uploadPhotoDialog" runat="server"/>
<!-- <![endif]-->

No need for the class attribute then

Target everything except ie..

<!--[if !IE]><!-->
    Your button goes here
 <!--<![endif]-->

You can add a class for your <html> element using conditional ments:

<!--[if IE]><html class="ie"><![endif]-->
<!--[if !IE]><!--><html><!--<![endif]-->

and then, assuming this button has a class .mybutton, you can target it like this

.ie .mybutton {display: none;}

And then you can use the same kind of targeting if you need to style anything else differently in IE.

本文标签: javascriptHow can I make a button hidden only when the user is browsing with IEStack Overflow