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

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

问题描述

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



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

 < table onload =函数()> 

这个应该加载javascript函数,但它不会显示对页面有任何影响。 onload 仅适用于 body 标签吗?

解决方案

Onload只能用于< body> < img> < script> ,< iframe>

由于 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆