For simplicity, i have the following file named test.jsp:
<script language="javascript">
alert("a$b".replace(/\$/g,"k"));
</script>
I put this file in my local server, then display it using firefox: http://localhost:8080/myproj/test.jsp. It works okay, the result alert string is:
akb
But when i put this file in a remote server and use the same firefox to display, it output is: a$bk which is incorrect for me.
Then i change the test.jsp content to:
<script language="javascript">
alert("a$b".replace(/\\$/g,"k"));
</script>
Note here i add two slashes instead of one. In this case it works in the remote server but not in local one.
Then i rename the file from test.jsp to test.html, but the content is the same as my first case, i.e.:
<script language="javascript">
alert("a$b".replace(/\$/g,"k"));
</script>
By using the same firefox, it works okay in both servers.
But my file needs to embed the javascript in jsp file. it is not allowed to use .html suffix for my file. What should I do to write a portable javascript in this scenario?
My local server uses tomcat-5.5.26; remote server uses tomcat-5.0.28. Firefox version is 3.0.4.