how to display a javascript var in html body
Try This...
<html><head> <script> function myFunction() { var number = "123"; document.getElementById("myText").innerHTML = number; } </script></head><body onload="myFunction()"> <h1>"The value for number is: " <span id="myText"></span></h1></body></html>
Use document.write().
<html><head> <script type="text/javascript"> var number = 123; </script></head><body> <h1> the value for number is: <script type="text/javascript"> document.write(number) </script> </h1></body></html>
<html><head><script type="text/javascript">var number = 123;var string = "abcd";function docWrite(variable) { document.write(variable);}</script></head><body><h1>the value for number is: <script>docWrite(number)</script></h1><h2>the text is: <script>docWrite(string)</script> </h2></body></html>
You can shorten document.write
but can't avoid <script>
tag