Javascript 在页面加载时运行JS脚本
我有一个.js文件,它是java file.jar的javascript翻译。我想在加载HTML页面后立即运行该文件。可能吗? 现在,使用以下代码运行该文件Javascript 在页面加载时运行JS脚本,javascript,Javascript,我有一个.js文件,它是java file.jar的javascript翻译。我想在加载HTML页面后立即运行该文件。可能吗? 现在,使用以下代码运行该文件 <div class="w3-twothird" align="center"> <script> cheerpjInit(); cheerpjCreateDisplay(500,400); cheerpjRunJar("/app/te
<div class="w3-twothird" align="center">
<script>
cheerpjInit();
cheerpjCreateDisplay(500,400);
cheerpjRunJar("/app/tesi/homepage/disgrafia.jar");
</script>
</div>
我只想使用js文件,不想使用jar。加载站点后运行代码的最简单方法是使用jQuery的ready函数。 是这样的
$(document).ready(function()
{
//Do the whatever you need to here
});
但是,请记住,页面上需要jQuery。最简单的方法是使用CDN。把这个贴在你的
干杯,希望有帮助
<script
src="https://code.jquery.com/jquery-3.4.1.min.js"
integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
crossorigin="anonymous">
</script>