JavaScript中的HTML加载 [英] Javascript onload in HTML
问题描述
我想问一个关于Javascript的 onload
的问题。
我正在用代码<%@ include file =body.jsp
编写一个JSP页面, 。包含的 body.jsp
包含:
< table onload =函数()>
这个应该加载javascript函数,但它不会显示对页面有任何影响。 onload
仅适用于 body
标签吗?
Onload只能用于< body>
,< img>
,< script> ,
< iframe> $ c $因为它告诉你何时加载了外部资源(图像,脚本,框架)或整个页面(body)
由于 HTML5 这些也可以触发一个 load 事件:< link>
,< style>
,< input type = image>
,< object>
支持尽管(比如较老的Android浏览器) p>
I want to ask a question about the Javascript’s onload
.
I’m writing a JSP page with the code <%@ include file ="body.jsp"
. The included body.jsp
contains:
<table onload="function()">
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 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
Since HTML5 these can also fire a load event: <link>
, <style>
, <input type=image>
, <object>
Support for these can still be a hit or miss though (e.g. older Android browsers)
这篇关于JavaScript中的HTML加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!