Support » Fixing WordPress » Problems with javascript

  • I know that there are many existing posts on putting javascript in posts but I cant make sense of them. Sorry.
    I want to put in the following script from an external site into a post on my site but it doesnt work at the mo when I paste it straight in.

    <!– Begin MagicSeaweed.com Chart Code
    (c) Metcentral Ltd 2005
    You are welcome to embed this code in your website to deliver our latest swell charts to
    surfers. We’d appreciate it if you leave this message and all code contained in this section
    as is and unmodified.
    If you link directly to the image it won’t work as we change the URL periodically.
    Thanks! – Ben –>
    <script type=”text/javascript”
    src=”http://data.metcentral.com/jscript/swellChart.js”>
    </script>
    <div style=”width: 550px; text-align: center”>
    MagicSeaweed.com Surf Forecast
    </div>
    <!– End MagicSeaweed.com Chart Code –>

    I read in one thread that I should ‘call it’ but I have no idea what this means. Could someone please give me a dummies guide to putting javascript in a post?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Link to the exact page on the above site which covers this ?

    heh – that’s BIG 🙂 http://www.tamba2.org.uk/T2/

    Edit your header template. Inside the
    <head> and </head>
    tags you want to place this bit:
    <script type="text/javascript"
    src="http://data.metcentral.com/jscript/swellChart.js">
    </script>

    Then wherever in your blog you want the images, place this:
    <div style="width: 550px; text-align: center">
    <a style="font-family: verdana; font-size: 10px; color: #000000" href="http://magicseaweed.com">MagicSeaweed.com Surf Forecast</a>
    </div>

    I’ve left out the credits stuff here for space, and you could also use css to do the styling for the second part.

    Just tried that on a test site, and if you paste it in exactly as shown, it won’t work. That’s because of the line break in the <script> tag. WP inserts <br> tags, which breaks the script.

    Edit this bit:

    <script type="text/javascript"
    src="http://data.metcentral.com/jscript/swellChart.js">
    </script>

    To this:

    <script type="text/javascript" src="http://data.metcentral.com/jscript/swellChart.js"></script>

    And it should work. (If it wraps above, just make sure there is no line break in your post between “text/javascript” and src.

    Sounds simple enough which makes me slightly warey.

    Thanks for your help

    That sure worked for me, thank you.

    Steve
    http://www.GeekTavern.com

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Problems with javascript’ is closed to new replies.