简体   繁体   中英

JavaScript working in Chrome but not in Firefox

I have a simple test page which seems to be working in Chrome but Not in Firefox.

The HTML Code is:

<html>
   <head>
      <title>Test Title</title>
   </head>

   <body>
      <script scr="test.js"> </script>

      <h1> Test </h1>
   </body>
</html>

The JavaScript code is:

alert("Hello World");
alert("Hello World");  
alert("Hello World");

Thanks in advance,

First of all your script elements source property got a typo and I would always use the MIME-Type info. try:

<script type="text/javascript" src="test.js"></script>

Furthermore, script definitions aswell as css links etc. should normaly be placed in the <head> section of your html document, not in the <body>

EDIT:

Actually the script MIME-Type is kinda deprecated and is not needed anymore. However, it does no harm if left in there.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM