Problem with writing js file

  • 1
  • Question
  • Updated 9 years ago
  • Answered

this may seem like a stupid question but I was wondering how to write a .js file?
I am just gonna use this simple code as an example:
<script type="text/javascript">
function message()
alert("This alert box was called with the onload event");

<body onload="message()">
But every time I save it as: test.js It never opens. Any ideas?

Photo of lambofgod


  • 875 Posts
  • 35 Reply Likes

Posted 9 years ago

  • 1
Photo of Christo


  • 95 Posts
  • 13 Reply Likes
Hi lambofgod.

You can write JavaScript using Yola, however, you will need to write it as *inline* javascript.

To run the above javascript on your site you would need to do the following:

1.) Drop an html widget onto your page
2.) place your JavaScript in the widget. e.g:

&lt;script type=&quot;text/javascript&quot;&gt;
window.onload = function message()
alert(&quot;This alert box was called with the onload event&quot;);

.. that should do the trick.

Some cautionary words on using JavaScript in Yola:
Errors in your javascript can cause problems with the SiteBuilder.

As such, it is recommended that you test your code on a separate page, then once it is working, copy the code into your live page - sp as to prevent yourself from loosing work.


1.) create a page called test
2.) drop an html widget onto your page
3.) do your coding
4.) once you are happy, copy your code and drop it into an html widget on your live page
5.) delete your test page