OnClick unexpectedly not working on Google sites in Chrome

I wrote a page that used onclick buttons to call a function as part of a set of problems and answers for my students. He worked from July without any problems until Friday, September 5, at least. Buttons today don’t function at all in Chrome, and I can’t understand why life is for me. They continue to function normally in IE.

I posted the simplest code that I could write that would not work below. It's terribly simple, and to be honest, I think that everything is in order. It seems to work if I paste all of this into the JSFiddle HTML field, but if I try to separate the script, it will do nothing. I don't know because it broke or because I separate it wrong, though.

I had problems debugging it, mainly because Google Sites completely rewrites your work in its own format, which is more or less unreadable without being made of silicon. When I load this and try to click, I get an exception:

Uncaught Error: shouldn't happen: ES5/3 object passed to makeDOMAccessible 

But I was completely unlucky in figuring out what was going on there, or was it even a problem or not.

I read a lot about the fact that Google Sites are picky about Javascript, and I don’t know if the problem is with the sites or Chrome or two together or something like that, but this is what I would like to understand, since the main part my students and I mostly use Chrome.

All of the code below is included in the inserted HTML code, as written, just FYI.

Sorry if this turns out to be a duplicate; I searched for quite a while and could not find a solution.

 <html> <body> <button onclick="Check()">Push Me</button> <script> function Check() { alert("It worked"); } </script> </body> </html> 

Any suggestions for fixing what I have (even if it is broken) or reusing it in a simple way that will work with sites and Chrome will be welcome. Thanks in advance.

Here is one full page that worked previously in Chrome and is no longer . It displayed table rows when pressing various buttons.

EDIT: This seems to work on older versions of Chrome. I guess I need to click on the Chrome forums this problem.

+7
javascript google-chrome onclick google-sites
source share
1 answer

The workaround suggested by epascarello using addEventListener instead of onclick events seems to work. I still can’t get the warning window in my example to work for any reason (regarding the Sites policy?), But the actual functionality that I wanted by setting the innerHTML of the paragraph object works correctly.

This is apparently a problem between Google and Chrome v.37 sites. I hope that this will be resolved in the near future.

Here is an example of equivalent code that works correctly.

 <html> <body> <button id="AnswerButton1">Check Answer 1</button> <p id="Answer1"></p> <script> document.getElementById("AnswerButton1").addEventListener("click",function(){Answer(1);}); function Answer(n){ document.getElementById("Answer"+n).innerHTML = "Answer to Number 1"; } </script> </body> </html> 

Thanks to those who helped.

+2
source share

All Articles