Zahema
Zahema

Reputation: 1415

Is there is a way to use <script> tag as you might use <%%> tag in asp or jsp?

To do something like that for example:

<script> for(var i=0; i<5; i+=1){ </script> <h1>hello</h1> <script> } </script>

If we used <%%> instead of <script> in aspx page it would print "hello" five times.

I just thought it would be really awesome if we can!

Upvotes: 0

Views: 26

Answers (1)

Julie Pelletier
Julie Pelletier

Reputation: 1716

No. That approach is only used in back-end languages such as ASP and PHP. In those languages, the engine parses the source code for ASP or PHP instructions in order to produce its output.

When dealing with JavaScript in an HTML document (inside <script> tags), it is the HTML document which is first interpreted, and during that parsing, the JavaScript is identified and run. JavaScript does not initially generate HTML and is merely included in it.

Upvotes: 2

Related Questions