putting javascript in external files

Discussion in 'JavaScript' started by Vic_mackey, May 12, 2008.

  1. #1
    Okay I have a problem with this. A design company sent me a new website I'd had done, but they've used javascript in the code itself rather than call it from external files. Its just a javascript to show the current time.

    To start with it looked like this:



    So its two javascripts. I put the first one in an external file and changed the first part to:
    <td height="15" class="white-medium-text"><script type="text/javascript" src="clock.js"></script>

    It worked fine like this. Now when I put the 2nd part into another external script, the clock isn't displaying. I dont want to leave the page full of javascript code, I'd prefer to get the 2nd part in an external file. Can anyone say why it is not working?

    thanks
     
    Vic_mackey, May 12, 2008 IP
  2. apmsolutions

    apmsolutions Peon

    Messages:
    66
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Is this on a public web site? Possible to see it in action?
     
    apmsolutions, May 12, 2008 IP
  3. GreatMetro

    GreatMetro Peon

    Messages:
    117
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Try adding:

    // <![CDATA[

    right after the opening script tag, and

    // ]]>

    right before the closing script tag at the bottom
     
    GreatMetro, May 12, 2008 IP
    Vic_mackey likes this.
  4. Vic_mackey

    Vic_mackey Banned

    Messages:
    2,093
    Likes Received:
    151
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thanks I'll try that, I'm off to football for a couple of days and leaving soon so will try as soon as I get back. apmsolutions sorry but its not a public site.
     
    Vic_mackey, May 13, 2008 IP