[Javascript] dynamic anchor tags, javascript, and JSP

Jay Wright jwright at once.com
Fri Feb 15 14:35:25 CST 2002


I have a web application written with jsp and a controller servlet.  I have
implemented a pop up window, that when completes it's task, uses clientside
java script to refresh it's opener and close itself.

<body onload="opener.location.href='/some/page';self.close();">

This works flawlessly.  At least it seems to.

However, when I add jsp code to this page, to refresh the opener and append
a dyanmically generated ANCHOR tag, it works perfectly well the first time,
but then fails to refresh the opener on subsequent tries.

<%
        String anchorString = (String) request.getAttribute("anchor");
        StringBuffer buf = new StringBuffer("");
        if (str!=null) buf.append("#").append(anchorString);
        System.out.println(buf.toString());
%>
<body
onload="opener.location.href='/some/page<%=buf.toString()%>';self.close();">


I KNOW that anchorString is not null, because I log it and it logs
correctly.  The first time this page is executed, it correctly refreshes the
opener (/some/page#anchor1), but the other attempts all fail to refresh,
leaving "/some/page#" in the browser address window, but never refreshing
the browser.

Any ideas why this might be?

Thanks,
Jay




More information about the Javascript mailing list