html tutorial - onload Attribute in HTML - html5 - html code - html form




Onload attribute in html

Learn html - html tutorial - Onload attribute in html - html examples - html programs

  • The onload attribute executes a script when an object has been loaded.
  • onload is most often used within the <body> element to execute a script once a web page has entirely loaded all content (including images, script files, CSS files, etc.).
  • For input elements, the onload attribute is only supported though <input type="image">
  • The onload attribute may be used to check the user's browser type and version, and load the proper version of the web page based on the information.
  • The onload attribute is a section of the Event Attributes.

Syntax for onload attribute in HTML:

<element onload="script">

Applies To:

Elements Attribute
<body> onload
<iframe> onload
<img> onload
<input> onload
<link> onload
<script> onload
<style> onload

Sample Coding for onload Attribute in HTML:

Tryit<!DOCTYPE html>
<html>
    <head>
        <title>Wikitechy HTML onload attribute</title>
        <script>
        function onLoad() 
        {
          alert("Wikitechy Page is loaded")
        }
        </script>
    </head>
    <body onload="onLoad()">
        <h2>Welcome to Wikitechy!</h2>
    </body>
</html>

Code Explanation for onload Attribute in HTML:

onload Attribute Code Explanation

  1. function onLoad () is a JavaScript function which is used to create an alert box when onload attribute is executed.
  2. The onload attribute executes when an associated element has been loaded.

Output for onload Attribute in HTML:

onload Attribute Tag Output

  1. When the page has been loaded the alert box displayed on the browser.
  2. onload Attribute Tag Output

  3. After clicking the ok button, the page has been displayed with the text welcome to Wikitechy!.

Browser Support for onload Attribute in HTML:

Yes Yes Yes Yes Yes

Related Searches to onload Attribute in html

Adblocker detected! Please consider reading this notice.

We've detected that you are using AdBlock Plus or some other adblocking software which is preventing the page from fully loading.

We don't have any banner, Flash, animation, obnoxious sound, or popup ad. We do not implement these annoying types of ads!

We need money to operate the site, and almost all of it comes from our online advertising.

Please add wikitechy.com to your ad blocking whitelist or disable your adblocking software.

×