Return to Support

insert javascript code

Home Forums Graphene WordPress theme Support insert javascript code

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #1237
    qazwsx
    Member

    Where is a good place to insert javascript code?

    <script type="text/javascript"> ...code... </script>

    and other code that goes in the <head>

    #22134
    Prasanna SP
    Member

    before the closing </body> tag

    #22135
    qazwsx
    Member

    I know where to put the code on a HTML site. What I’m asking is can I put it in with the google analytics code theme options or do a action hook on the google analytics one and put the code in that widget?

    #22136
    Prasanna SP
    Member

    What I meant was to add the script in footer.php before the closing </body> tag.

    Yes, I think you can paste the code along with Google Analytics code in Graphene Options.

    #22137
    qazwsx
    Member

    What im trying to do is insert google maps into a page. I’ve done this before in plain websites (html). But i’ve been unable to do it in a webpage that is done with wordpress. An example of what im trying to build is:

    http://www.barlowchristmas.com/map.php

    #22138
    Josh
    Member

    Are you using Google Maps to generate the code? If so, they should give you an iframe or embed code. You can switch to HTML while editing a post/page and insert the code where you would like to display the map.

    Or, you can use my plugin, and it will add a button for inserting iframes and embed codes for you, if you don’t like HTML. All you’ll have to do is paste the code Google gives you.

    http://wordpress.org/extend/plugins/ultimate-tinymce/

    #22139
    qazwsx
    Member

    @Josh

    I’m not using the iframe or the embed code to make the google map. I need to have a map made from an external file and have a side bar with the map. Like the one that is linked above.

    Embedding a map from the iframe or embed code works nice and easy. But getting that sidebar to work with the map seems to be very difficult. It seems that in order to have a sidebar with the map that pulls the info from the map, the map has to be made with the Maps API. Which is fine for a html website. But for some reason every time i try (many different ways) to put that code into wordpress the map breaks in many different ways.

    #22140

    Where is a good place to insert javascript code?

    <script type="text/javascript"> ...code... </script>

    and other code that goes in the <head>

    Attach it to the wp_head() action hook. See this: http://codex.wordpress.org/Function_Reference/wp_head

    #22141
    Syahir Hakim
    Keymaster
    Quote:
    But for some reason every time i try (many different ways) to put that code into wordpress the map breaks in many different ways.

    I may be wrong, but I think WordPress strips out <iframe> by default, which is why the normal Maps embed code don’t work.

    #22142
    qazwsx
    Member

    This might sound odd, but using <iframe> is the only way i can get it to work. I don’t really want to do it this way, I would rather have the map built on the page than on a different html page and just linked in a frame.

    #22143

    Okay, here’s a really weird idea, but it might be what you are looking for.

    Try creating just a plain vanilla html file that contains the code for the map and the sidebar like in the link you provided. (Which is very, very interesting…I have never seen Google maps for this purpose.) Upload that to some safe place on your blog, and then use an <iframe> to place that file on your blog.

    Completely untested, but all my brain can come up with right now.

    #22144
    qazwsx
    Member

    @Kenneth

    That is the only way I could get it to work. I didn’t know if a <iframe> would be the best way of doing it. I was trying to get it to work within wordpress, but everything i’ve tried doesn’t work. (<iframe> does work).

    (Which is very, very interesting…I have never seen Google maps for this purpose.)

    Why is this such an odd way of doing it? How else could the data be displayed on the map with a usable sidebar?

    #22145
    Josh
    Member

    I think Ken was commenting on how cool and “fun” this usage of google maps is. Usually, we see it for a business location, or a tourist attraction… never have we seen it used as a “route” with multiple “stops”. I love the idea also!!

    I don’t know very much about the google maps api. I’ll try to take a look at it and see how they are reloading that map without having to reload the entire page. I would imagine each link in the sidebar has a script associated with it when you click it… which then loads the corresponding map.

    Although I have no idea… but I’ll try to learn a little about it.

    #22146
    qazwsx
    Member

    @Josh

    The map used in that page is not API V3. I can’t remember if its Ver 1 or 2. But the way it works is the side bar links to a JavaScript function that changes the lat/long on the map. The page never refreshes. The map does not ‘load or refresh’ for each location. It just kinda moves. In the same way as holding down the mouse and dragging it side to side.

Viewing 14 posts - 1 through 14 (of 14 total)

You must be logged in to reply to this topic.