Why does IE8 not recognize the JavaScript .Click event?

0

I'm making an application in which I need to send an asp button by means of JavaScript after uploading a file in a FileUpload, I use the document.getElementById('nameButton').click(); sentence in Chrome, Firefox works correctly but in IE8 crashea and throws me the following message:

and this is my code:

<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <script type="text/javascript">
        function precargar() {
            document.getElementById('<%=btnCargaImg.ClientID%>').click();
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <div> <asp:Label ID="lblMsj" runat="server" Text="..."></asp:Label><br /><br />
              <asp:FileUpload ID="fileUp" runat="server" onchange="precargar();" 
                OnPreRender="fileUp_PreRender"></asp:FileUpload><br /><br />
            <br /><br />
        </div>
        <asp:Button ID="btnCargarImg" runat="server" Text="Cargar Imagen" OnClick="btnCargarImg_Click" />
    </form>
</body>

This is the result in Google Chrome and Firefox ...

    
asked by Uri Sánchez 07.02.2018 в 17:07
source

2 answers

0

Probably related to an IE 8 bug that has to do with the color of the background.

I leave the textual quote, source: link

  

Browser compatibility

     

Internet Explorer

     

Internet Explorer 8 & 9 suffer   from a bug where elements with a computed background-color of   transparent that are overlaid on top of other element (s) will not receive   click events Any click events will be fired at the underlying   element (s) instead. See this live example for a demonstration.

     

Known workarounds for this bug:

     

For IE9 only: Set background-color: rgba (0,0,0,0) Set opacity: 0 and   an explicit background-color other than transparent
  For IE8 and IE9: Set filter: alpha (opacity = 0); and an explicit background-color other   than transparent

    
answered by 07.02.2018 в 21:17
0

Thanks to everyone but I could not resolve this detail. What I did was to perform a C # method and consume it from Ajax to work, otherwise I could not replicate my flow.

    
answered by 12.02.2018 в 16:42