PDA

View Full Version : setting window source from frame using JS


nickkish
03-14-2003, 03:36 PM
I would like to programmatically call a webpage from inside a frame. In HTML, it would look something like this:

<A HREF="main.jsp" TARGET="_top">some text</A>

The problem with this is that the link must be pressed and I would like to do it programmatically. I tried using jsp:forword or response.sendRedirect, but found out that I couldn't use the TARGET attribute with either of those. But I did hear that it could be done using JavaScript.

I plan on embedding the JavaScript into a JSP (basically HTML with JAVA embedded in it) with the <SCRIPT> tag, which I have successfully used before.

Any help would be greatly appreciated. Thanks in advance.

Nick
:confused:

Roy Sinclair
03-14-2003, 07:50 PM
Javascript doesn't need a "target", it has objects which reference those windows.

top.location.href = "main.jsp"

nickkish
03-14-2003, 07:57 PM
Thanks, I think that will do it.

:thumbsup: