Zahema Zahema - 2 years ago 75
HTML Question

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>
<script> } </script>

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

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

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download