Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simple Javascript not working: <div onload="alert("Hi");" > [duplicate]

Tags:

I'm trying to get a really simple to alert() to pop up as soon as a div loads. Unfortunately it is not working, and I can't figure out why.

Here is the code:

<html>
    <head>
        <title>My Site</title>
        <link rel="stylesheet" type="text/css" href="style2.css">
        <script type="text/javascript" src="js/jquery_1.4.2.js"></script>
        <script type="text/javascript" src="js/alertjs.js"></script>
    </head>
    <body>
        <div id="background_logo" onload="pop_alert();">
            <img src="mysiteLogo.png">
        </div>
        <div id="signup">
            <p id="instruction"> Get on board! </br> Enter your email to receive updates:</p>
            <script type="text/javascript" src="js/form-validation.js"></script>

        </div>
    </body>


</html>

And the JavaScript is just this:

function pop_alert(){
    alert("This is an alert");
}