Event-Attribut "onchange" on Internet Explorer does not work at all

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Daniel1111
    New Member
    • Jun 2019
    • 31

    Event-Attribut "onchange" on Internet Explorer does not work at all

    I have the same question as



    But now I am using Internet Explorer 11 and I always get errors when "onchange" is called. My JavaScript cannot be opened. I have used "onclick" but same problem.
    The error which occurs is: The value of property "JavaScript_fun ction" is null or undefined, no function-object.
    Any ideas?
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5388

    #2
    please post the code that you use (at least an example of it) - the events are fired as you can see - otherwise there wouldn't be a error message - so your errors will be in the call itself or somewhere in the code that is called.

    Comment

    • Daniel1111
      New Member
      • Jun 2019
      • 31

      #3
      So this is my xslt code. I do have a JavaScript Code but it is empty, but still the same error. Line 15 and line 26 are the important lines with "onchange"
      Code:
      <?xml version="1.0" encoding="UTF-8"?>
      <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
      <xsl:template match="/">
      <html>
          <head><title>Secrets</title></head>
      
      <body onload="script_for_all_functions();">
      
      <table id="myTable">
              <colgroup>
                  <col width="150" style="background-color:e2e2e2"></col>         
              </colgroup>
              <tr  style ="background-color:a5a5a5">
                  <th rowspan="2">plane
                      <select id="modelRangeDropdown" onchange="script_for_all_functions()">
                           <option selected="selected">All</option>
                           <xsl:for-each select="logstore/Fahrzeug">
                              <option>
                               <xsl:value-of select="Name" />
                              </option>
                           </xsl:for-each>                    
                      </select>                   
                  </th>   
                  <th colspan="2" width="330">date</th>
                  <th rowspan="2">Secret
                      <input type="checkbox" id="identicalSecrets" onchange="script_for_all_functions()"></input>
                      <label for="identicalSecrets">hide identical secrets</label>
                  </th>
              </tr>
      
              <tr>
                  <th align="center" style="background-color:a5a5a5">begin</th>
                  <th align="center" style="background-color:a5a5a5">end</th>
              </tr>
              <xsl:for-each select="logstore/plane/trigger">
                  <tr>
                      <td align="center"><xsl:value-of select="../Name"/></td>
                      <td align="center"><xsl:value-of select="date"/></td>
                      <td align="center"><xsl:value-of select="date"/></td>
                      <td><xsl:value-of select="secret"/></td>
                  </tr>
              </xsl:for-each>
          </table>    
          <script type="text/javascript" src="/C:/eclipse-workspace/adclasses/src/inbox/script_for_all_functions.js"></script>    
      </body>
      </html>
      </xsl:template>
      </xsl:stylesheet>

      Comment

      • gits
        Recognized Expert Moderator Expert
        • May 2007
        • 5388

        #4
        where is the javascript code included in the final page? so far i only can see that you call a method script_for_all_ functions but its not defined anywhere nor is it included?

        PS: i see the include now at the bottom - so post that code
        PPS: why is there a / at the beginning of the include path?
        Last edited by gits; Jun 3 '19, 12:19 PM.

        Comment

        • Daniel1111
          New Member
          • Jun 2019
          • 31

          #5
          I deleted everything from my Javascript code to make sure that the problem is not JavaScript.
          But here is the code:
          Code:
          function script_for_all_functions() {
          
          }
          And why there is a "/" at the beginning of the include path is that it won't work otherwise on Firefox. I don't know why but it's only working with "/" on Firefox. --> No problem on firefox but on IE.
          PS: I mean IE only throw errors because of onchange and not because of "/" at the beginning. I am pretty sure "/" is correct

          Comment

          • gits
            Recognized Expert Moderator Expert
            • May 2007
            • 5388

            #6
            so it's working in firefox but not in IE? just put an alert right in the first line of your included file script_for_all_ functions.js like:

            Code:
            alert('script loaded');
            so when your script can load correctly you will see that alert on your page. its impossible that an onchange event should behave differently on firefox and IE when its just called the same way - the error must be somewhere else - and i suspect the include so that the function is just undefined.

            Comment

            • Daniel1111
              New Member
              • Jun 2019
              • 31

              #7
              Ok I will try this. What would you recommend how to change the include? Because it's working on FF...

              Comment

              • gits
                Recognized Expert Moderator Expert
                • May 2007
                • 5388

                #8
                try to use relative paths - and usually i would set up a local webserver for testing the app so that you have a real 'web-runtime'. you will have to change those absolute include paths when you deploy that to a production system - so its always error prone to have such pure local development systems that are not near a real system.

                Comment

                • Rabbit
                  Recognized Expert MVP
                  • Jan 2007
                  • 12517

                  #9
                  You're trying to point to a javascript on your local C drive? That's not going to work from the browser's perspective. You need to use a path that the browser can access. It's not your computer that's interpreting the location of the javascript file, it's the user's browser that's pulling it from their end. They have no concept of your local C drive.

                  Comment

                  • Daniel1111
                    New Member
                    • Jun 2019
                    • 31

                    #10
                    I understand what you are writing but why should it not work on my computer? It may not work on any other users computer. But it still work on Firefox, why not on IE.
                    But I will try to use relative paths now.

                    Update: When using relative path and alert IE will run my script.

                    Update2: The problem is
                    Code:
                    let row of rows
                    .
                    How should I change that?
                    Last edited by Daniel1111; Jun 4 '19, 08:33 AM. Reason: Updates

                    Comment

                    • gits
                      Recognized Expert Moderator Expert
                      • May 2007
                      • 5388

                      #11
                      so - as suspected it was the include path. basically this should work in all browsers the same now - and you can put the alert into your event-handling function to see that even the events (especially that onchange event) should work across all the browsers.

                      PS: using the alert for such debugging is basically a bad idea and i suggest not to let it become a habit. i just suggested it so far for the sake of simplicity. a better way with nearly the same effect would be to work with the developer console and console.log(msg ) instead of the alert. alerts are modal thus you always have to act with a click or a keypress to get rid of the popup - this is especially not fun when you put alerts into a loop :)
                      Last edited by gits; Jun 4 '19, 08:54 AM. Reason: add hint regarding alerts

                      Comment

                      • Daniel1111
                        New Member
                        • Jun 2019
                        • 31

                        #12
                        Thanks for that. Do you also have a quick solution for my second update that IE will not work with
                        Code:
                        for (let row of rows) {...}
                        ?
                        I know that IE does not like "let" normally. So I can replace it with "var". But there is still a problem with "row of rows"

                        Comment

                        • gits
                          Recognized Expert Moderator Expert
                          • May 2007
                          • 5388

                          #13
                          just use the for...in loop - in case you use it for an array and have that extended somehow you would need to check for non-native properties as well - simply speaking for...in treats the array like a 'normal' object - more detailed explaination is here:

                          The for...of statement executes a loop that operates on a sequence of values sourced from an iterable object. Iterable objects include instances of built-ins such as Array, String, TypedArray, Map, Set, NodeList (and other DOM collections), as well as the arguments object, generators produced by generator functions, and user-defined iterables.
                          Last edited by gits; Jun 4 '19, 09:40 AM. Reason: add MDN link for reference

                          Comment

                          • Daniel1111
                            New Member
                            • Jun 2019
                            • 31

                            #14
                            Okay I got it. Is there any website which describes the different of functions between FF and IE? Now I have the problem for
                            Code:
                            cells = row.getElementsByTagName("td");
                            Error is: The property of "getElementsByT agname" of an undefined cannot be called.

                            Comment

                            • gits
                              Recognized Expert Moderator Expert
                              • May 2007
                              • 5388

                              #15
                              as i said - the problem you have now is that row will be undefined or such since you replaced of by in. Depending on how your rows structure looks like, it can behave differently. It should produce errors in all browsers in case its that issue that i suspect. so basically seeing more of the code would help much - since its like guesswork at the moment where i only assume a lot of things.

                              having said the above - a good starting point to find out about browser supports and quirks is here:



                              and an ES6 comaptibilty table can be found here:

                              Last edited by gits; Jun 4 '19, 10:44 AM. Reason: added ES6 compat-table-link

                              Comment

                              Working...