Embedded Javascript Code inside HTML Tags

by Didin J. on Dec 12, 2016 Embedded Javascript Code inside HTML Tags

Sometimes it's necessary to embedded Javascript code inside HTML tags for some cases.

This time I will show you how to embedded your javascript code inside or inline of formatted HTML tags like H1, H2, P, etc. Sometimes it's necessary to embedded Javascript code inside HTML tags for some cases. First, step as usually create new HTML page and fill with some tags and embedded javascript code. Here's our example:

<html>
  <head><title>Embedded Javascript in Formatted HTML Tags</title></head>
  <body>
    <h1>
      <script type="text/javascript">
        document.write("Welcome to Javascript Tutorial");
      </script>
    </h1>
    <h2>
      <script type="text/javascript">
        document.write("For the World Wide Web People");
      </script>
    </h2>
    <p>
      <script type="text/javascript">
        document.write("Lorem ipsum dolor sit amet, ne mea cibo omittam assueverit. Ut est omittam eligendi. Ad pro veniam dicunt. Eos te nostrud partiendo, eu mundi reprehendunt eam. Audiam vivendo apeirian cu has, alia cibo antiopam et vis.");
      </script>
    </p>
  </body>
</html>

As you see, there are H1, H2 and P tags that where javascript code inside. Javascript code only shows or print out a text to displayed inside a browser. And here's the result:

Simply that it's for this time.

Thank You

The following resources might be useful for you:

Loading…