How To Add A Body.OnLoad Function?

  • 1
  • Question
  • Updated 8 years ago
  • Answered
is there a way to add a 'body onLoad' function, when i don't have access to the 'head'?

i've seen two methods, but they don't seem to work for me:

or

why won't these work, in an html widget? is the code above incorrect? is there a way that will work with yola?

thanks!
Photo of johnywhy

johnywhy

  • 34 Posts
  • 0 Reply Likes
  • confident

Posted 8 years ago

  • 1
Photo of Sanja

Sanja, Official Rep

  • 10698 Posts
  • 495 Reply Likes
Hello Johnywhy

It should be possible to add a 'body onLoad" function. The code you posted did not show up. Can you please try encoding your code and pasting it again on the forum. Here's a encoder you can use: http://forsite.synthasite.com/encoder...

Also, please share your URL so that we can take a look at what you're trying to do.

Thank you for your patience as we work on this together.
Photo of johnywhy

johnywhy

  • 34 Posts
  • 0 Reply Likes
<script language="javascript">
document.onload= yourfunction
</script>

or

<script type="text/javascript">
<!--
window.onload = function () {alert()}
// -->
</script>

thanks!
Photo of johnywhy

johnywhy

  • 34 Posts
  • 0 Reply Likes
here's the yola page in question:
http://bayviewfootprints.yolasite.com...

here's the code i'm trying to add:
http://code.google.com/apis/maps/docu...
Photo of Sanja

Sanja, Official Rep

  • 10698 Posts
  • 495 Reply Likes
Hey Johnywhy

I am trying to figure this out. I did notice that you do not have an API code which is required with your Google Maps. Here's where you can grab the API code: http://code.google.com/apis/maps/sign...

Then, you'll need to read the instructions and insert your API key. Hopefully that might work!
Photo of johnywhy

johnywhy

  • 34 Posts
  • 0 Reply Likes
hi sanja

google maps api version 3 does not require an api code anymore:
http://code.google.com/apis/maps/docu...

the code in my yola page comes straight from the google example here:
http://code.google.com/apis/maps/docu...

this example maps code works perfectly outside the yola system, but not in yola. in yola, i'm forced to put the script tags outside the head, in html widgets.

i think the issue might not be onload. the page below proves that by simply putting the call in a script tag, i can call a function that displays an alert when the page loads:
http://bayviewfootprints.yolasite.com...

so, it seems there's some other conflict between yola and the maps api, which breaks the maps api.
Photo of johnywhy

johnywhy

  • 34 Posts
  • 0 Reply Likes
fyi, i noticed my browser status bar displayed "connecting to gg.map" or something like that, right after i edited the html widget, but no map shows.
Photo of Sanja

Sanja, Official Rep

  • 10698 Posts
  • 495 Reply Likes
Hey Johnywhy

I'm sorry but I'm just not able to figure it out. I was only able to get as far as getting a brown background to come up on my site using the API key code.

I suggest contacting Google Maps and perhaps they might have a suggestion.

Sorry that I was not able to resolve this for you.