[offtopic solved] Problem with my HTML5 JS template ?

For other topics related to the FreeBASIC project or its community.
D.J.Peters
Posts: 8208
Joined: May 28, 2005 3:28
Contact:

[offtopic solved] Problem with my HTML5 JS template ?

Postby D.J.Peters » Feb 19, 2020 19:25

Sorry isn't FreeBASIC but what are wrong with my template ?
May be the solution is simple but i'm blind sometimes ;-)

if I press [F12] i get the console an this message:
SyntaxError: unexpected token: '{' ReferenceError: main is not defined


Joshy

Code: Select all

<!DOCTYPE html>
<html lang='en'>
  <head>
    <meta charset='utf-8' />
    <title>JS and HTML5 canvas template!</title>
    <!-- comment in HTML -->
    <style>
      html, body {
        padding: 0;
        margin: 0;
        overflow: hidden;
      }
    </style>
  </head>

  <body onload='main()'>
    <noscript>Your browser does not support JavaScript or is disabled !</noscript>
    <canvas id='renderer'>Please use a browser that supports a HTML5 'canvas' tag !</canvas>
    <!-- block comment in HTML
    <script src='./my_relative_path/my_include_file.js'></script>
    -->
    <script>
    // single line comment in JS
    main() {
      /*
        block
        comment
        in JS
      */
    }
    </script>
  </body>
</html>
Last edited by D.J.Peters on Feb 19, 2020 20:08, edited 1 time in total.
Imortis
Moderator
Posts: 1744
Joined: Jun 02, 2005 15:10
Location: USA
Contact:

Re: [offtopic]Problem with my HTML5 JS template ?

Postby Imortis » Feb 19, 2020 19:57

You need to add "function" in front of the function named "main".

Code: Select all

function main() {
 //stuff
 }
badidea
Posts: 2223
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: [offtopic]Problem with my HTML5 JS template ?

Postby badidea » Feb 19, 2020 20:07

I don't know, where (what program) do you press F12?
Maybe "function main() { } " ? (wild guess)
D.J.Peters
Posts: 8208
Joined: May 28, 2005 3:28
Contact:

Re: [offtopic]Problem with my HTML5 JS template ?

Postby D.J.Peters » Feb 19, 2020 20:08

yes i'm blind ;-)

thank you

Joshy
Tourist Trap
Posts: 2958
Joined: Jun 02, 2015 16:24

Re: [offtopic]Problem with my HTML5 JS template ?

Postby Tourist Trap » Mar 19, 2020 8:13

badidea wrote:I don't know, where (what program) do you press F12?
Maybe "function main() { } " ? (wild guess)

Probably in the browser to show the console.

Return to “Community Discussion”

Who is online

Users browsing this forum: No registered users and 4 guests