Is it to hide my javascript in the project directory?
tangara goh
Ranch Hand
Joined: Dec 27, 2009
Posts: 125
posted
0
Dear experts,
I'm wondering is it possible to hide my javascripts that do the validation of forms under the directory of my project folder, just like the way CSS can be hidden away in the directory? However, I'm not sure how it can be done. Hope someone can share with me how. Many thanks.
OK, well "hiding" is certainly not the right word for that.
So you are asking if you can move the JavaScript out of the page and into a separate file? If so, then yes. Create a file containing the script, give it a file type of .js, and use the src attribute on the script tag to reference it.
Example:
[Moved to the HTML forum.]
tangara goh
Ranch Hand
Joined: Dec 27, 2009
Posts: 125
posted
0
Bear Bibeault wrote:
So you are asking if you can move the JavaScript out of the page and into a separate file? If so, then yes. Create a file containing the script, give it a file type of .js, and use the src attribute on the script tag to reference it.
Example:
[Moved to the HTML forum.]
OK. But, the thing is I can't find a folder for this js in Netbean IDE. After right-clicking my project name, should I file it under others+ ?
It doesn't matter where you put it as long as it within the web app, but not under WEB-INF. Forming the URL to the file should be done using full server-relative addressing which is discussed in the JSP FAQ.