Home > DeveloperSection > Forums > html onload not running javascript
Pravesh Singh

Total Post:411

Posted on    September-03-2013 7:35 AM


 1 Reply(s)
 944  View(s)
Rate this:

I'm writing a game in javascript, and I had the world generator running fine, but when I created a startup function to run multiple things at once, my code doesn't run at all anymore. Can anyone see my problem?


<title>Project Rust</title>

<!-- <link href="/YOUR_PATH/favicon.ico" rel="icon" type="image/x-icon" /> -->

<script src="Scripts/startup.js"></script>

<script src="Scripts/drawmap.js"></script>

<script src="Scripts/maps.js"></script>

<script src="Scripts/mapread.js"></script>

<script src="Scripts/mainchar.js"></script>


<body bgcolor="#BFE3FF" onload="startup()">


startup.js: startup(){ alert("start"); drawmap(Screen[0]); mainchar(); }

Any help will be appreciated.

Sumit Kesarwani

Total Post:378

Posted on    September-03-2013 7:55 AM

Hi Pravesh,

You should set the type to the script tags:

<script type="text/javascript" src="Scripts/startup.js"></script>

Also, you need to use the function keyword to define a function in javascript:

function startup(){





If it's still now working, open your browser's javascript console and you should see the error.

Hope this will solve your problem.

Don't want to miss updates? Please click the below button!

Follow MindStick