These solutions will work:
<body onload="script();">
or
document.onload = function ...
or even
window.onload = function ...
Note that the last option is a better way to go since it is unobstrusive and is considered more standard.
Related Posts:
- How to make JavaScript execute after page load?
- How to make JavaScript execute after page load?
- Onclick javascript to make browser go back to previous page?
- Javascript: getElementById vs getElementsById (both works on different pages)
- Check if an element contains a class in JavaScript?
- How can I change an element’s class with JavaScript?
- How do I programmatically set the value of a select box element using JavaScript?
- How can I capture the right-click event in JavaScript?
- Edit webpage with javascript trick – how to “unedit”?
- jQuery document.createElement equivalent?
- Automatically pausing html5 video as the ‘next’ button is pressed (javascript/ jquery)
- Is it possible to write data to file using only JavaScript?
- How can I scroll to an element using jQuery?
- jQuery.click() vs onClick
- Remove CSS class from element with JavaScript (no jQuery) [duplicate]
- Include another HTML file in a HTML file
- Is it possible to write data to file using only JavaScript?
- Set cookie and get cookie with JavaScript
- Which is better: or
- How to resolve the C:\fakepath?
- Why is my Javascript not working?
- How can I get the values of data attributes in JavaScript code?
- mailto using javascript
- mailto using javascript
- Mailto using Javascript?
- How to change css property using javascript
- JavaScript get element by name
- javascript close current window
- I am trying to make a simple toggle button in javascript
- How to call a JavaScript function within an HTML body
- How to save user input into a variable in HTML and JavaScript
- Hiding a button in Javascript
- Show/hide ‘div’ using JavaScript
- Get HTML code using JavaScript with a URL
- Uncaught TypeError: Cannot read property ‘top’ of undefined
- Calculate percentage Javascript
- How to display image with JavaScript?
- How can I select an element by name with jQuery?
- Resize image with javascript canvas (smoothly)
- JavaScript function onhover in
- Hide element by class in pure Javascript
- Parse an HTML string with JS
- How to play a mp3 using Javascript? [duplicate]
- mailto using javascript
- Function not defined javascript
- How to submit a form with JavaScript by clicking a link?
- How to call a REST web service API from JavaScript?
- Check a radio button with javascript
- Is it possible to append to innerHTML without destroying descendants’ event listeners?
- AppendChild() is not a function javascript
- JavaScript: Get image dimensions
- Why write script type=”text/javascript” when the mime type is set by the server?
- Retrieve the position (X,Y) of an HTML element
- How to select an input element by value using javascript?
- javascript window.location in new tab
- How to create a hidden in JavaScript?
- Cannot read property ‘style’ of undefined — Uncaught Type Error
- Why onbeforeunload event is not firing
- How to make HTML element resizable using pure Javascript?
- How do I clear the content of a div using JavaScript?
- Open source social media icons to download and use on website? [closed]
- What does In html mean
- Center image horizontally within a div
- Center-align a HTML table
- Is there any way to change input type=”date” format?
- How to center a “position: absolute” element
- How to run python script in HTML?
- Export html table data to Excel using JavaScript / JQuery is not working properly in chrome browser
- CSS color vs. background-color vs. background?
- Getting “Failed to load resource: net::ERR_FILE_NOT_FOUND” when trying to load a background image
- CSS: background-color only inside the margin
- Stretch background image css?
- Set cellpadding and cellspacing in CSS?
- html not linking css
- Jquery button click() function is not working
- Make iframe automatically adjust height according to the contents without using scrollbar?
- Removing border from table cells
- How do I check whether a checkbox is checked in jQuery?
- Setting table row height
- How do I disable the resizable property of a textarea?
- Is there any reason for using WebGL instead of 2D Canvas for 2D games/apps?
- jQuery count child elements
- Is it possible to set the equivalent of a src attribute of an img tag in CSS?
- Align an element to bottom with flexbox
- Video auto play is not working in Safari and Chrome desktop browser
- How can I change the thickness of my
tag- How to make a div 100% height of the browser window
- How to resize an image to fit in the browser window?
- In which directory do I find the HTML file of my wordpress pages?
- Preserve white-space in Page
- HTML / Javascript in custom field textarea?
- How do we remove mystical [X] from text? Image included
- Insert “javascript:void(0);” into URL
- Add Adsense to a website but the server responds with error 510 [closed]
- Insert data through a script directly in the db
- Using Tags Instead of Categories for site structure
- Line break before headings () appears from nowhere
- Tidy HTML formatting in Gutenberg HTML blocks
- Target a specific container to style on WordPress storefront theme
- Adding Custom HTML/CSS/JS code in specific page