Javascript onload无法正常工作 [英] Javascript onload not working
问题描述
我正在使用外部javascript文件,我用它来存储我的所有javascript函数。接下来我试图通过正文调用函数,使用下一行代码:
I am using an external javascript file, which I am using to store all my javascript functions in. Next I am trying to call a function from the body, using the next line of code:
<body onload="imageRefreshBig()">
这个函数唯一能做的就是弹出一个警告框,这就是它应该是什么做。我知道这是一个相当简单的问题,但是我一直在试图找到问题/解决这个问题的问题,而且没有任何工作。
The only thing that this function does is making an alert box pop up, well that's what's it supposed to do. I know this is a rather easy question but I have been banging my head against a wall trying to find a problem/fix for this issue and nothing is working.
我也是在我脑中包含javascript文件:
I also include the javascript file in my head:
<script type="text/javascript" src="javascript.js"></script>
但您可能认为这不起作用。任何人都可以解释我的语法/思维出了什么问题。我唯一能想到的是我的文档没有正确加载或我有语法错误。
But as you probably see this isn't working. Could anyone explain what is going wrong with my syntax/thinking. The only thing I could think of is that either my document is not being loaded properly or that I have a syntax error.
推荐答案
您可以尝试在javascript中使用:
You can try use in javascript:
window.onload = function() {
alert("let's go!");
}
这是一个很好的做法,单独的html javascript
Its a good practice separate javascript of html
这篇关于Javascript onload无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!