Google Blockly Inject

199 views
Skip to first unread message

Sudha Ravali

unread,
Sep 19, 2018, 4:58:18 PM9/19/18
to Blockly
Hi,

I am trying to create new games using Google Blockly for Web. I downloaded the ZIP file from GitHub.
I have written the code to inject the workspace into a blank webpage, but when I open my HTML file in Chrome, all it shows me a blank page.
This is my code. My webpage file, i.e. index.html is in the google-blockly(the main folder downloaded) > demos> me. So I assume the path for blockly_compressed and blocks_compressed is also correct. 

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<script src= "../../blockly_compressed.js"></script>
<script src= "../../blocks_compressed.js"></script>
<script src= "../../msg/js/en.js"></script>
<style>
    body {
      background-color: #fff;
      font-family: sans-serif;
    }
    h1 {
      font-weight: normal;
      font-size: 140%;
    }
  </style>
</head>
<body>
<div id="blocklyDiv" style="height: 480px; width: 600px;"></div>

<xml id="toolbox" style="display: none">
<block type="controls_if"></block>
<block type="controls_repeat_ext"></block>
<block type="logic_compare"></block>
<block type="math_number"></block>
<block type="math_arithmetic"></block>
<block type="text"></block>
<block type="text_print"></block>
</xml>

  <script>
  var workspace = Blockly.inject('blocklyDiv',{media:'../../media',toolbox: document.getElementbyId('toolbox')});
  </script>

</body>
</html>

If I add any other diagrams/shapes like a circle/square in my code, it does show all that when the webpage loads, except for the workspace/blocks.

Thank you
Sudha

Erik Pasternak

unread,
Sep 19, 2018, 10:09:14 PM9/19/18
to Blockly
Hi Sudha,

Are there any errors in the console?
Reply all
Reply to author
Forward
0 new messages