I’m having a problem on our site where the google maps is not showing anymore as of a couple of days ago.
Here’s two links to the pages in which it’s not working:
link 1 – A project detail page
link 2 – A project category page
They all work from the same type of code and were working great until a day ago.
Last time it didn’t work was because someone didn’t insert the correct number type on the lat long coordinates section.
Here’s the code that did it in case anyone runs into the same problem. Please see answer below (thank you Jonathan Kuhn!)
<script type="text/javascript">
Shadowbox.init({
// let's skip the automatic setup because we don't have any
// properly configured link elements on the page
skipSetup: true
});
<?php
session_start();
if (empty($_SESSION['count'])) {
$_SESSION['count'] = 1;
}
else {
$_SESSION['count']++;
}
?>
window.onload = function() {
// open a welcome message as soon as the window loads
<?php
if ($_SESSION['count'] == 1) {
?>
Shadowbox.open({
content: '<div id="welcome-msg"><p style="padding:4px 30px; margin:4px; color:#fff;">Awesome stories, photos, news, and more on our projects, straight to your inbox.</p><p style="padding:4px 30px; margin:4px; color:#fff;">Enter your e-mail and click Submit to join.</p><form method="post" name="newsletter" action="include/newsletter_submit.php" onsubmit="return validateForm_newsletter()" style="padding:10px 30px;"><input type="text" name="email_address" class="newsletter_textbox"> <input type="submit" name="button" class="newsletter_button" value="Submit" style="margin-top:10px;"><p style="padding:18px 15px; margin:4px; color:#fff;">You can also enter your e-mail at the bottom of our homepage.</p></form></div>',
player: "html",
title: "Get our friendly updates!",
height: 250,
width: 350
});
<?php } ?>
};
</script>
I believe you are overwriting the body onload that usually runs your initialize function with a window.onload that runs an empty function. Viewing the source of the first link, right around line 69 you have:
which I think is overwriting the onload in the body tag. in firebug console if you run
document.body.onload.toString()it shows that empty function, comment and all.edit to add example wrapper function:
essentially what I do is check if there is a window.onload already and if there is, save that function to a temp variable. then assign a new window.onload that calls the temp function. I use Function.apply to pass in any arguments that window.onload recieves which might differ based on the browser but this assures that the temp function will get all the same arguments that the original function would get.