In article < >,
enlightened us with...
> I wonder if anyone can tell me if this is possible? I have a JSP that
> appears in a frame on another page. Is it possible to read the URL of
> the page hosting my 'framed' JSP.
>
> e.g. www.mysite.com has a page mypage.htm
> mypage.htm has a frame containing myjsp.jps
>
> Can myjsp.jsp read the parent's URL (www.mysite.com/mypage.htm) ?
>
> I appreciate any advise.
>
Not that I know of, since server-side, there is no concept of a frame.
But javascript can.
You can use javascript to check it and post back to the server.
javascript can see it with
window.parent.location
You can post it back with the url and parse it.
Note: must be in body of html document so javascript runs
(following works in theory: untested)
<%
String page = request.getParameter("page");
if (page == null || page.length() == 0)
{
%>
<script type="text/javascript">
if (window.parent.location)
{
var p = window.parent.location;
// reload location with page param
window.location = window.location+ "?page="+p;
}
</script>
<%
}
else
{
// do whatever with page var
}
%>
--
--
~kaeli~
If it's tourist season, why can't we shoot them?
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace