Reputation: 183
I want a JavaScript function to execute when the page loads.
I added an onload
attribute to my <form>
tag, but the alert
is not executed.
What am I doing wrong?
<form name=myfm method=post action=quiz.php onload = alert('hello')>
Upvotes: 11
Views: 46319
Reputation: 567
// javaScript
window.onload = function{
alert("loaded");
}
// jquery
$(document).ready(function() {
$("#div-id").click(function(){
alert("the page is loaded");
});
});
Upvotes: 4
Reputation: 418
try adding the onload
to the body
tag
<body onload="alert('Hello World')">
Upvotes: 12