Javascript in a JSP/JSTL page

M

Manuel

Hello.

I need insert a piece of javascript code in a JSTL page, that it will
execute always, that is, without events. I use the tag <script> but
this make that the web don't load correctly.


Any idea?
 
T

Tim Slattery

Manuel said:
Hello.

I need insert a piece of javascript code in a JSTL page, that it will
execute always, that is, without events. I use the tag <script> but
this make that the web don't load correctly.

JSTL and JSP run on the server. The result is an HTML page which is
sent to the client. That page may contain Javascript, which will run
on the client.

Javascript that's not part of a function will run when it's
encountered. Something like this:

<script type="text/javascript">
var a;
a = 5;
alert ("a=" + 5);
</script>

will cause a message box to appear as soon as the browser parses it.
 
M

Manuel

JSTL and JSP run on the server. The result is an HTML page which is
sent to the client. That page may contain Javascript, which will run
on the client.

Javascript that's not part of a function will run when it's
encountered. Something like this:

<script type="text/javascript">
var a;
a = 5;
alert ("a=" + 5);
</script>

will cause a message box to appear as soon as the browser parses it.

I know it. But that crash and the web is not loaded correctly and i
don't know why :(
 
T

Tim Slattery

Manuel said:
I know it. But that crash and the web is not loaded correctly and i
don't know why :(

If the script refers to something that hasn't been loaded yet, it will
fail. Try moving your script block to the end of the HTML page.
 
M

Manuel

If the script refers to something that hasn't been loaded yet, it will
fail. Try moving your script block to the end of the HTML page.

well, I call a some function that it is at an external file that is
loaded in the beginning of the webpage. All the ways, I tried with a
simple code that this:

<script type="text/javascript">
alert("hello world");
</script>

I don't understand :(((
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,163
Messages
2,570,897
Members
47,434
Latest member
TobiasLoan

Latest Threads

Top