www.webdeveloper.com
Results 1 to 3 of 3

Thread: Problem with js calling from html

  1. #1
    Join Date
    Aug 2011
    Posts
    1

    Problem with js calling from html

    Hello.

    I have a problem with javascript: when I add "<-script type="text/javascript" src="content.js">, javascript stop running. I have nothing in content.js, is just for test.
    I made a short script without "content.js" and working. Why?

    Example: THIS WORK
    <html>
    <head>
    <title>trala</title>
    <script type="text/javascript">
    function jucator(){
    alert('cata');
    }
    </script>
    </head>
    <body>
    <form>
    <input type="button" name="cauta" value="Cauta" onclick="jucator()" />
    </form>
    </body>
    </html>

    THIS don't work
    <html>
    <head>
    <title>trala</title>
    <script type="text/javascript" src="content.js">
    <script type="text/javascript">
    function jucator(e){
    alert('cata');
    }
    </script>
    </head>
    <body>
    <form>
    <input type="button" name="cauta" value="Cauta" onclick="jucator()" />
    </form>
    </body>
    </html>

  2. #2
    Join Date
    Apr 2006
    Location
    Perth
    Posts
    154
    You need to close the SCRIPT tag for an external source reference:

    <script type="text/javascript" src="content.js"></script>
    Colin Fiat Simple Solutions To Complex Problems

  3. #3
    Join Date
    Sep 2008
    Location
    Akron, OH
    Posts
    1,133
    You're script tag isn't closed. Try:

    Code:
    <script type="text/javascript" src="content.js"></script>
    I'm always up for networking with fellow web professionals. Connect with me on LinkedIn if you like!

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