www.webdeveloper.com
Results 1 to 4 of 4

Thread: js file does not load in explorer

  1. #1
    Join Date
    Jul 2007
    Posts
    2

    js file does not load in explorer

    Hi all,
    I am new to js. When my javascript is placed inside the html, both explorer and firefox load it correctly. When javascript is an external file and i call it from src="file.js" , it only loads correctly in firefox and not in explorer.

    Does anyone know why placing the file externally will make it not load?

    Thanks!

  2. #2
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    Should work. can you give us details? An example, a link, something?

  3. #3
    Join Date
    Jul 2007
    Posts
    2
    i found the button also doesn't show up in explorer.. thanks for your help

    test.html=====>

    <html>
    <head>
    <script type="text/javascript" src="file.js">
    </head>
    <body>

    <input type="button" onclick="disp_alert()" value="hello" />

    </body>
    </html>

    file.js=======>

    function disp_alert()
    {
    alert("WORLD!!")
    }

  4. #4
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    Give your page a DOCTYPE. I see you use XHTML way of coding, thus either you use an XHTML DTD:

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html>
    ......
    <form>
    <input type="button" onclick="disp_alert()" value="hello" />
    </form>
    ......
    </html>
    Or you use a HTML, say transitional DTD, and write the tags in HTML way
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"  "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    ...
    <form>
    <input type="button" onclick="disp_alert()" value="hello">
    </form>
    
    ...
    </html>
    Note that you must nest the input control into a form, at least when dealing with the XHTML way of coding.

    About DTD:
    http://www.w3.org/QA/Tips/Doctype
    About XHTML and DTD
    http://en.wikipedia.org/wiki/XHTML

    You may also google for detailed information about HTML transitional/strict and XHTML transitional/strict coding

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles