How to Embed Your Scratch Applet in HTML5

Scratch in HTML5 Even though there is a Scratch project website where the Scratch community uploads its projects, there is also an alternative method to embed Scratch within your own website.  Since TeachMeProgramming.com is also teaching HTML5, we are happy to show you how to embed your Scratch applet using HTML5.  Read on to find out more.

 

 

Pre HTML5 versions support the <applet> tag, however, this tag is deprecated in HTML5.  HTML5 encourages the use of the <object> tag instead, which is brand new, that can be used to embed media in your website, such as videos and audio.

You will need 2 files in addition to your Scratch projects in the same directory as your HTML5 file:

  1. ScratchApplet.jar
  2. soundbank.gm

The following code is used to embed a sample applet:

How to embed applet in HTML5

In the code above, the name of the Scratch project is "abc-song.sb" and is assigned to the attribute "value".  The applet's dimensions (height and width) are configurable.

You can view the sample HTML5 by clicking on the image.

Enjoy!

Advertisements

Who's Online

We have 4 guests online

Website Grader

Advertisements

Visitors


Visits today:31
Visits yesterday:31
Visits in this month:1266
Visits total:34046
Impressions today:156
Impressions total:197246
Bots today:78
Date since:2009-10-18

Countries

Top 7:
Unknown flag 33%Unknown (11095)
United States flag 25%United States (8579)
United Kingdom flag 9%United Kingdom (3155)
Israel flag 4%Israel (1334)
Germany flag 3%Germany (999)
India flag 3%India (972)
Netherlands flag 2%Netherlands (581)
34046 visits from 144 countries

Welcome, Visitors!