I have a .js file that is the javascript translation of a java file.jar. I would like to run the file as soon as the HTML page is loaded. Is it possible? now the file is run using the following code
<div class="w3-twothird" align="center">
<script>
cheerpjInit();
cheerpjCreateDisplay(500,400);
cheerpjRunJar("/app/tesi/homepage/disgrafia.jar");
</script>
</div>
I'd like to use only the js file and not the jar.
The simplest way to run a piece of code once a site has loaded is using jQuery's ready()
function. Goes something like this
$(document).ready(function()
{
//Do the whatever you need to here
});
Do keep in mind, however, that you will need jQuery on your page. Simplest way to get it is using CDN. Just paste this in your <head> </head>
<script
src="https://code.jquery.com/jquery-3.4.1.min.js"
integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
crossorigin="anonymous">
</script>
Cheers, hope it helps <3
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.