Forums Register Login

ways of getting context name in javascript

+Pie Number of slices to send: Send
i want to load page as follows

var frame = document.createElement('iframe');
frame.src = "/birthDayReminder/search.htm";

here i am giving context name as hard coded value

is there any way to get this context name dynamically

some work around in java is
1] define hidden variable like
<input type="hidden" id="contextName" value="<%=request.getContextPath()%>">

2] access this variable in java script as follows
var contextName=document.getElementById("contextName");frame.src = contextName.value+"/search.htm";
[ October 29, 2007: Message edited by: ganesh pol ]
+Pie Number of slices to send: Send
Please see this JSP FAQ entry.
+Pie Number of slices to send: Send
A very helpful answer.
The moth suit and wings road is much more exciting than taxes. Or this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1244 times.
Similar Threads
opening new window
Tomcat4.1 ConnectionPool ( javax.naming.NameNot Found Exception: Name java:
STRUTS:client-side validation using validation.xml for hidden field results in error
How to get s:hidden value to java class
how to use jsp variables in javascript
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 07:29:20.