How to run javascript in Chrome or Firefox browser

I use javascript in my jsp file, in IE11 it works fine, but I cannot run and display in Chrome or Firefox browser, I try to convert to jquery, but not ok

This is my jsp:

<head>
   <script language="javascript">

   // functions
   function examStart()
   {
       ... 
   }

   function goout_onclick()
   {
       ...
   }
   function GetQ()
   {
       ...  
   }
   <script>
 </head>

<body>
     <input type="image" src="<%= imagesDir%>/bt_start.gif" <% if(yn_sametime.equalsIgnoreCase("N")) { %> onClick="JavaScript:examStart();" <% } else { %> onclick="JavaScript:examStart();" <% } %> id="startbutton" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('startbutton','','<%= imagesDir%>/bt_start_up.gif',1)" name="startbutton">
</body>

This is a bug from the debug console:

Uncaught ReferenceError: ScriptEngineMajorVersion is not defined
TypeError: Cannot read property '-1' of undefined

How to run javascript in Chrome or Firefox?

+4
source share
1 answer

In some situations, javascript may not work in chrome, especially if you use this onclick listener. So, it would be better if you can use jquery instead. Use this jquery code to replace onclick in javascript. I had the same problem in here

<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"</script>
             $(document).ready(function () {
                   $("#but1").click(function(){
                   alert("The click has happened");
                   });
             }
             <input type='button' id='but1'/>
0
source

Source: https://habr.com/ru/post/1685839/


All Articles