Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7178637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:57:39+00:00 2026-05-28T16:57:39+00:00

New to JavaScript, and what I’m doing below seems right from all the Google

  • 0

New to JavaScript, and what I’m doing below seems right from all the Google RTFM’ing I’ve been doing, but it isn’t working. So I decided to reach out for help since I’m stuck.

I have a JavaScript that lives in my HTML’s < head> document…

<script type="text/javascript" src="http://example.com/scripts/scripts.js"></script>

The contents are the Google Maps API. Previously I’ve had the JavaScript run from a DIV onMouseOver. This way I could run the script multiple times – because I need multiple different maps per page (it’s a photoblog). I know the script works, because it’s working today.

<div class="location" onmouseover="initalizeMap('gmaps1832588575', '42.102500,-72.587333')"></div>

I am trying to figure out how to have this script called from outside of a div. For example, a static div that always displays the map. So, I was under the impression I can move the initializeMap function out of the onmouseover, and into it’s own < script> section. However, it’s not working. Here’s what I have:

    <div class="location">
<a href="http://maps.google.com/maps?q=40.756167+-73.978833&z=14" target="_blank">New York, NY, US</a>

    <script type="text/javascript" language="JavaScript">initalizeMap('gmaps2021396674', '40.756167,-73.978833');</script>

    <div class="map_holder">
    <div class="map" id="gmaps2021396674">
    </div></div></div>

Like I said, I need this to run multiple times, and this code works when I call on it from a div onMouseOver.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T16:57:39+00:00Added an answer on May 28, 2026 at 4:57 pm

    When you put code inside a script tag within the page, it runs as soon as that script tag is loaded. This may be before the div it is referring to has been loaded, so it doesn’t work because it’s running too early (the mouseover approach worked because you can’t do your mouseover until the qhole page loads).

    You can try moving your script tag to the end of the page, or you can trigger it from the HTML body tag’s onload event, or you can look at jQuery and use $(document).ready().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

New to javascript, but I'm sure this is easy. Unfortunately, most of the google
I've been doing some reading about two (relatively) new concepts in the Javascript language
I'm new to javascript/jquery and I've done some poking around the web, but I
I have been developing a new JavaScript application which is rapidly growing in size.
what is the right way to do revokeAuthorization in new Javascript SDK?
New to javascript/jquery and having a hard time with using this or $(this) to
im new to javascript and am intersted in creating a small o3d script: <!DOCTYPE
I'm relatively new to Javascript and was wondering if there's a quick way to
Being fairly new to JavaScript, I'm unable to discern when to use each of
I am new to JavaScript OOP. Can you please explain the difference between the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.