HTML 中的 Javascript 加载 [英] Javascript onload in HTML

查看:17
本文介绍了HTML 中的 Javascript 加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想问一个关于Javascript的onload的问题.

I want to ask a question about the Javascript’s onload.

我正在编写一个 JSP 页面,代码为 <%@ include file ="body.jsp".包含的 body.jsp 包含:

I’m writing a JSP page with the code <%@ include file ="body.jsp". The included body.jsp contains:

<table onload="function()">

应该加载javascript函数,但它似乎对页面没有任何影响.onload 只能在 body 标签上使用吗?

This should load the javascript function, but it doesn't appear to have any effect on the page. Is onload only usable on the body tag?

推荐答案

Onload 只能用于 , , <script>, <iframe> 标签,因为它告诉你外部资源(图像、脚本、框架)或整个页面(正文)何时被加载

Onload can only be used for <body>, <img>, <script>, <iframe> tags, because it tells you when an external resource (image, script, frame) or the whole page (body) has been loaded

由于 HTML5 这些也可以触发 load 事件:,