How to call a JavaScript function in HTML on load -
javascript code trying call html.
var classlist = new array ["bio1300","csci12"]; function classmenu(classlist) { return (classlist.tostring); };
this html code trying call javascript function inside of on load of page.
<li> <script type="text/javascript" src="javascript inprog.js"> function classmenu() { console.log(classlist.tostring); } </script> </li>
please help. have many other functions trying call in manner both arrays , contain mathematical calculations.
there few issues code snippet you've provided. firstly, it's considered best practice add <script>
tags inside <head>
of document or @ end of document when loading javascript files. secondly, source reference incorrect. assuming javascript file inprog.js @ same directory level html file, change script link this:
<script src="inprog.js"></script>
once you've ammended how you're loading javascript file page, can make call function inside <script>
tag anywhere on page, so:
<script>classmenu(params);</script>
also, i'd recommend adding console.log statement function you're calling.
hopefully helps.
Comments
Post a Comment