Event not fired RRS feed

  • Question

  • User364663285 posted

    Event below is not fired when Html page is loaded. What to adjust?

      	function event0() {
    		$hdr1 = "Logon Page";
    		echo "Hello";
    <body onload="event0()">

    Monday, February 10, 2020 8:34 AM

All replies

  • User753101303 posted


    Use F12 Console for example to see  JavaScript error rather than reading your code and wondering what happens. If echo is defined somewhere else it might be :

    function event0() {
        echo("Hello"); // rather than echo "Hello"

    Or is this even JavaScript (looks like PHP ???)

    Edit: for example I see an "Uncaught SyntaxError: Unexpected string" on the echo "Hello"; line because Javascript uses functions and so you need to use echo("Hello"); (and then  it tells "echo is not defined") while it could work if you really defined an echo function somewhere etc....

    As you can see  F12 Console gives a quite clear starting point compared with guessing from the code (and for example one have  no way to know if you defined an echo function). I still wonder if it's not some confusion between JavaScript and what looks PHP  ????

    Monday, February 10, 2020 9:43 AM
  • User364663285 posted

    Sorry to that I got

    (index):18 Uncaught ReferenceError: echo is not defined

        at event0 ((index):18)


    to this line.


    Monday, February 10, 2020 10:04 AM
  • User753101303 posted

    So as I suspected earlier, it now means that the "echo" function is not defined. Do you have this defined in some other script file that you should reference from your page? What is supposed to do this function?

    Also you have a https://www.w3schools.com/php/func_string_echo.asp  statement in PHP which is why I wonder if there is not some kind of confusion between JavaScript and something you saw that uses PHP ???

    Monday, February 10, 2020 10:19 AM
  • User288213138 posted

    Hi wmec,

    echo "Hello";

    As PatriceSc said, echo() is the php function, If you want to achieve the same function in asp.net, you can use the document.write method.


    More information about document.write() you can refer to this link: https://www.w3schools.com/jsref/met_doc_write.asp

    Best regards,


    Tuesday, February 11, 2020 3:01 AM