Skip to content Skip to sidebar Skip to footer

Html Body "onload" Is Not Working In Chrome

I have written sample web application with servlets and jsp. As per the below code the action url should be executed automatically according to the 'onload'. I have written this be

Solution 1:

After some investigation finally i got solution for my problem. I forgot to set the Content type for the response in the servlet.

response.setContentType("text/html; charset=UTF-8");

Chrome browser will display response in the form of html page by using above line.

Solution 2:

You can try function in script tag of that html page.

<script>functionmyfunction() {
     alert("This is the first.");
    }

    window.onload = function()
    {
     myfunction;
    }
  </script>

Post a Comment for "Html Body "onload" Is Not Working In Chrome"