Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I close a an IFRAME?

Status
Not open for further replies.

celia05es

Programmer
Jan 10, 2002
81
US
Hi,

I have the folloing jsp file:
Code:
<iframe src="includes/logo.html" width="100%" height="100"
 scrolling="no"
marginwidth="0" marginheight="0">
</iframe>
<br>
<iframe src="login.jsp" width="100%" height="450"
marginwidth="0" marginheight="0">
</iframe>

The screen is divided in two screens:
- logo.html (that will never change) and
- login.jsp

The login.jsp file will then call another page, that will call another page, etc.
In each page, there is a link to the page before.
My problem is as follows:
When the user clicks "exit", the exit.jsp file is called.
The exit.jsp file does a few things (among them: close session, etc.) AND calls again the login.jsp file
Code:
<jsp:forward page="login.jsp" />

and ....Another iframe is then opened!!! within the old one.
I mean that in the frame that initially contained "login.jsp", a new frame is opened that contains "login.jsp".
Obviously, I don't want that. I want the frame that contains the login.jsp file to be closed and the new frame with login.jsp opened.

How can I do it?

THanks
 
Why not have your initial page NOT called login.jsp - maybe something else, like "initial.jsp", which loads "login.jsp" in the iframe.

Then remove the logo from login.jsp, and place it in "initial.jsp".

Hope this helps,
Dan


[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Well... if you wanted to go for a javascript solution, then this might be what you want:

Code:
<html>
<head>
<title>login.jsp</title>
<script type="text/javascript">
function checkFrames() {
	if (top!=self) top.location.href = location.href;
}
onload = checkFrames;
</script>
</head>
<body>
<p>This is the login.jsp page that we prevent from being framed.</p>
</body>
</html>

This tiny bit of javascript, when put on any page, will attempt to reload the page and "escape" from any frames (including iframes). Ideally you would put this javascript into the login.jsp page.

Let me know if it works for you! Be aware that if the users have javascript switched off, nothing will happen [smile]

Cheers,
Jeff

[tt]Jeff's Page [/tt][tt]@[/tt][tt] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top