473,396 Members | 2,011 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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

I have the same question as

https://bytes.com/topic/javascript/a...hange-checkbox

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_function" is null or undefined, no function-object.
Any ideas?
Jun 3 '19 #1
23 2322
gits
5,390 Expert Mod 4TB
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.
Jun 3 '19 #2
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"
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
  3. <xsl:template match="/">
  4. <html>
  5.     <head><title>Secrets</title></head>
  6.  
  7. <body onload="script_for_all_functions();">
  8.  
  9. <table id="myTable">
  10.         <colgroup>
  11.             <col width="150" style="background-color:e2e2e2"></col>         
  12.         </colgroup>
  13.         <tr  style ="background-color:a5a5a5">
  14.             <th rowspan="2">plane
  15.                 <select id="modelRangeDropdown" onchange="script_for_all_functions()">
  16.                      <option selected="selected">All</option>
  17.                      <xsl:for-each select="logstore/Fahrzeug">
  18.                         <option>
  19.                          <xsl:value-of select="Name" />
  20.                         </option>
  21.                      </xsl:for-each>                    
  22.                 </select>                   
  23.             </th>   
  24.             <th colspan="2" width="330">date</th>
  25.             <th rowspan="2">Secret
  26.                 <input type="checkbox" id="identicalSecrets" onchange="script_for_all_functions()"></input>
  27.                 <label for="identicalSecrets">hide identical secrets</label>
  28.             </th>
  29.         </tr>
  30.  
  31.         <tr>
  32.             <th align="center" style="background-color:a5a5a5">begin</th>
  33.             <th align="center" style="background-color:a5a5a5">end</th>
  34.         </tr>
  35.         <xsl:for-each select="logstore/plane/trigger">
  36.             <tr>
  37.                 <td align="center"><xsl:value-of select="../Name"/></td>
  38.                 <td align="center"><xsl:value-of select="date"/></td>
  39.                 <td align="center"><xsl:value-of select="date"/></td>
  40.                 <td><xsl:value-of select="secret"/></td>
  41.             </tr>
  42.         </xsl:for-each>
  43.     </table>    
  44.     <script type="text/javascript" src="/C:/eclipse-workspace/adclasses/src/inbox/script_for_all_functions.js"></script>    
  45. </body>
  46. </html>
  47. </xsl:template>
  48. </xsl:stylesheet>
  49.  
Jun 3 '19 #3
gits
5,390 Expert Mod 4TB
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?
Jun 3 '19 #4
I deleted everything from my Javascript code to make sure that the problem is not JavaScript.
But here is the code:
Expand|Select|Wrap|Line Numbers
  1. function script_for_all_functions() {
  2.  
  3. }
  4.  
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
Jun 3 '19 #5
gits
5,390 Expert Mod 4TB
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:

Expand|Select|Wrap|Line Numbers
  1. 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.
Jun 3 '19 #6
Ok I will try this. What would you recommend how to change the include? Because it's working on FF...
Jun 3 '19 #7
gits
5,390 Expert Mod 4TB
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.
Jun 3 '19 #8
Rabbit
12,516 Expert Mod 8TB
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.
Jun 3 '19 #9
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
Expand|Select|Wrap|Line Numbers
  1. let row of rows
.
How should I change that?
Jun 4 '19 #10
gits
5,390 Expert Mod 4TB
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 :)
Jun 4 '19 #11
Thanks for that. Do you also have a quick solution for my second update that IE will not work with
Expand|Select|Wrap|Line Numbers
  1. 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"
Jun 4 '19 #12
gits
5,390 Expert Mod 4TB
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:

https://developer.mozilla.org/en-US/...ments/for...of
Jun 4 '19 #13
Okay I got it. Is there any website which describes the different of functions between FF and IE? Now I have the problem for
Expand|Select|Wrap|Line Numbers
  1. cells = row.getElementsByTagName("td");
Error is: The property of "getElementsByTagname" of an undefined cannot be called.
Jun 4 '19 #14
gits
5,390 Expert Mod 4TB
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:

https://www.quirksmode.org/

and an ES6 comaptibilty table can be found here:

http://kangax.github.io/compat-table/es6/
Jun 4 '19 #15
This is a part of my code. As commands you can see which if-cases will be executed and which not. I am using the development console but do not get any errors so far but the if-case is being executed in FF:
Expand|Select|Wrap|Line Numbers
  1. function test_internet_explorer() {
  2.  
  3.     // Variables
  4.     var table, checkBox, filterCheckBox, filterDropDown, rows, cells, secret, modelRange, dropdown, rowCount;
  5.     dropdown = document.getElementById('modelRangeDropdown');
  6.     table = document.getElementById('myTable');
  7.     rowCount = table.rows.length; 
  8.     checkBox=document.getElementById('identicalSecrets');
  9.     rows = table.getElementsByTagName("tr");             
  10.     filterCheckBox = checkBox.checked; 
  11.     filterDropDown = dropdown.value;
  12.     var index = 0; 
  13.  
  14.  
  15.     for (var i = 0; i < rows.length; i++) { 
  16.         var row = rows[i];
  17.         cells = row.getElementsByTagName("td"); 
  18.         modelRange = cells[0] || null; 
  19.         secret = cells[3]; 
  20.  
  21.         // does not execute
  22.         if (i > 2 && modelRange.textContent != rows[i - 1].getElementsByTagName("td")[0].textContent) {
  23.             rows[i - 1].getElementsByTagName("td")[2].firstChild.nodeValue = "-";
  24.             alert('script loaded');
  25.         }
  26.  
  27.         // does execute
  28.         if (i === rowCount - 1) { 
  29.             rows[i].getElementsByTagName("td")[2].firstChild.nodeValue = "-";
  30.         }
  31.  
  32.         // does not execute
  33.         if (i > 2 && modelRange.textContent === rows[i - 1].getElementsByTagName("td")[0].textContent) {
  34.             rows[i - 1].getElementsByTagName("td")[2].firstChild.nodeValue = rows[i].getElementsByTagName("td")[1].textContent;
  35.         }
  36.     }
  37.  
  38. }
Jun 4 '19 #16
gits
5,390 Expert Mod 4TB
well i could imagine that IE retrieves a thead as well - between line 9 and 10 insert:

Expand|Select|Wrap|Line Numbers
  1. console.log(rows);
that should let you inspect the collection retrieved in line 9 at the console.
Jun 4 '19 #17
That did not solve the problem. If I change
Expand|Select|Wrap|Line Numbers
  1. if (i > 2 && modelRange.textContent != rows[i - 1].getElementsByTagName("td")[0].textContent) {
to
Expand|Select|Wrap|Line Numbers
  1. if ( i > 2)
it will execute the if-case. So it has to be a problem with
Expand|Select|Wrap|Line Numbers
  1. .textContent
or
Expand|Select|Wrap|Line Numbers
  1. .getElementsByTagName
but I don't know why and I don't know how to change that as there is no error and it is working with Firefox.
Jun 4 '19 #18
gits
5,390 Expert Mod 4TB
you have to debug that. check what exactly is processed by IE - the simplest way is to log into the console and see if it processes what you expect there.

- IE should support textContent since v9
- getElementsByTagName is working in all browsers - but IE might process an imaginary thead as well so that can mess your code up here
Jun 4 '19 #19
I think I have found the problem. I have tried
Expand|Select|Wrap|Line Numbers
  1. innerText
instead of
Expand|Select|Wrap|Line Numbers
  1. textContent
and it is working.
As I don't need to change content in a <script> or a <style> it is working for me.
Jun 4 '19 #20
gits
5,390 Expert Mod 4TB
well - good you found a workaround - but its still strange since IE shouldn't have an issue with textContent - cant test that myself though since i dont have an IE here at the moment.
Jun 4 '19 #21
gits
5,390 Expert Mod 4TB
ok - i did test textContent in IE 11 now with a table and getElementsByTagName - it works as expected and exactly the same in Firefox 67. So there isn't a problem with the methods but with the contained text in the nodes. this even explains while its working with innerText which basically ommits additional spaces or leading/trailing linebreaks and such - which i think will be the problem in the 'non-working' script above.
Jun 4 '19 #22
Thanks for testing. But do you have an explanation why, if I had hyphens, linebreaks etc., it does only work on IE11 when not using things like that?
PS: Hyphens, linebreaks etc. do work with Firefox
Jun 4 '19 #23
gits
5,390 Expert Mod 4TB
as i said - it can only be tested with the actual data / complete case - that i cannot know. i simulated exactly the steps you had in your shown script with a static html page and table with text where it did work exactly the same in both browsers. if you have a dynamically created table/content it can be different - IE was always working a bit different when creating tables per JavaScript for example.
Jun 4 '19 #24

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Joshua Smith | last post by:
Before I get started with my questions, I'd like to say thanks to everyone for the time they may take helping me. I'm fairly new to style sheets, so please excuse any ignorance. I've set up my...
6
by: Tim Johnson | last post by:
Hello All: Using javascript to dynamically add row elements to a table. as in ..... row.setAttribute("bgcolor",rowColor); // or cell.setAttribute("bgcolor",rowColor); Using firefox or...
3
by: Mitch | last post by:
i would like to display a swf that takes up the entire browser. netscape and firefox display the following code as i intend, but internet explorer does not. could i get some help? <HTML>...
0
by: Kerem Gümrükcü | last post by:
Hi, i use the internet explorer embeeded in SHDocVw.dll but my WebBrowser Object does not fire any event. is this a Bug and how can i "receive" events from my Browser class...? Everything...
2
by: Slawek | last post by:
Hi everyone, I need to display aspx page containing xml (using xml control) in the same way as Internet Explorer does (with nodes, and "+"). Is there any way to get xslt stylesheet used in...
2
by: Leszek Taratuta | last post by:
Hello, I am using the following code to prevent users to see the previous pages: Response.CacheControl = "no-cache"; Response.AddHeader( "Pragma", "no-cache" ); Response.Expires = -1; When...
3
by: VK | last post by:
Internet Explorer 7 beta 2 preview CNET Editor review: <http://reviews.cnet.com/Internet_Explorer_7_for_XP_SP2_Beta_2/4505-3514_7-31454661-2.html?tag=nl.e415> Summary (my personal review...
1
by: Frederik Vanderhaegen | last post by:
Hi, I'm writing an application which handles Internet Explorer Automation. Through the application I'm able to automate logon on a certain webpage. When I automate the click on the logon button,...
7
by: raknin | last post by:
I'm using AJAX on my website, but internet explorer does not seem to actually be refreshing the data I retrieve via AJAX when I refresh the page. For example, I have a button that when pressed uses...
1
by: shiva raju | last post by:
i have problem in only internet explorer,its work good in google chrome, i have problem in below code. when i want to call delete cookie, cookies are deleted but the below function is not called for...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.