Separating Javascript functions
Posted
by msharma
on Stack Overflow
See other posts from Stack Overflow
or by msharma
Published on 2010-03-19T16:56:13Z
Indexed on
2010/03/19
17:01 UTC
Read the original article
Hit count: 312
JavaScript
|include
I am wondering how javascripts get included in a jsp - can we put any code which the jsp will recognize and not just javascript code only in the .js file?
I have some common javascript code which needs to get executed on different pages, so I decided to place it in its own separate .js file and include it on all jsps which call that function.
The js function now refers to a key from a properties file and some other non-javascript code:
function openPrivacyStmntWindow(){
var url = <h:outputText escape="false" value="\"#{urls.url_privacyStatement}\";" />
newwindow=window.open(url,'Terms','height=600,width=800,left=300,top=100,scrollbars=1');
newwindow.focus();
return false;
}
This function worked just fine when it was included in the jsp itself. Now that I have separated it into its own file it doesnt, do I need to include the properties bundle in this file.
The value="\"#{urls.url_privacyStatement}\";" is referring to a bundle called "urls" which has a key called "url_privacyStatement"
Also in Line 1 var url = <h:outputText escape="false" value="\"#{urls.url_privacyStatement}\";" />
the <h:outputText escape="false" ... />
will it cause any issues?
Thanks.
© Stack Overflow or respective owner