WordPress.org

Ready to get started?Download WordPress

Forums

Problems with javascript (8 posts)

  1. dominic_traynor
    Member
    Posted 8 years ago #

    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?

  2. Mark (podz)
    Support Maven
    Posted 8 years ago #

    Link to the exact page on the above site which covers this ?

  3. dominic_traynor
    Member
    Posted 8 years ago #

  4. Mark (podz)
    Support Maven
    Posted 8 years ago #

    heh - that's BIG :) http://www.tamba2.org.uk/T2/

  5. Mark (podz)
    Support Maven
    Posted 8 years ago #

    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.

  6. lbessant

    Posted 8 years ago #

    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.

  7. dominic_traynor
    Member
    Posted 8 years ago #

    Sounds simple enough which makes me slightly warey.

    Thanks for your help

  8. stfarm
    Member
    Posted 8 years ago #

    That sure worked for me, thank you.

    Steve
    http://www.GeekTavern.com

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags