How to call a javaScript Function in jsp on page load without using <body onload=“disableView()”>

前端 未结 1 495
日久生厌
日久生厌 2021-02-14 08:36

How can a JavaScript function in JSP be called during page load without using


I have to call this functio

相关标签:
1条回答
  • 2021-02-14 08:52

    Either use window.onload this way

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

    or alternatively

    <script>
        window.onload = functionName;
    </script>
    

    (yes, without the parentheses)


    Or just put the script at the very bottom of page, right before </body>. At that point, all HTML DOM elements are ready to be accessed by document functions.

    <body>
        ...
    
        <script>
            functionName();
        </script>
    </body>
    
    0 讨论(0)
提交回复
热议问题