JavaScript On MyPost

Proper Use of JavaScript on MyPost

A functionality that we wanted to incorporate to give our users the complete freedom to make their posts exactly the way they wanted was JavaScript. With JavaScript, there are hundreds of thousands of scripts to enhance how a webpage can look and what it can do.

You can add the JavaScript commands to the post by clicking SHOW ADVANCED OPTIONS and adding it to the Custom JavaScript section.

  • window.alert('Hello World');

With this simple command, a message can popup and alert the user with a command prompt. These messages are great for getting the user attention or forcing them to acknowledge something.

How it would actually look in a post:

  • window.alert('Hello World');

This is what the example above looks like in an actual post: Window.Alert Sample

We have started a collection of useful JavaScript Samples to help get you started.

To call an external script:

Do not put quotation marks around the external URL. They will automatically be added later.

We have already included several common JavaScript source files to help out including:

  • jQuery v1.4.4
  • jQuery v1.8.0
  • jQuery Mousewheel 3.1.13
  • jQuery UI - v1.11.2
  • Modernizr 2.8.3
You do not need to call these scripts.

We highly recommend that you use our Minify JS script located just below the text editor in Tools to minify your JavaScript for optimal functioning.

When minifying JavaScript, leave out the <script> tags, as they aren't necessary and you won't be using them anyway.

With MyPost, you cannot call JavaScript using the <script>.

You must put it in BBCode format: {script} {/script} or when calling a file: {script src=file.js} {/script} (replace squiggly brackets { } with brackets [ ]).

Try it yourself!

Return to Blog