• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2024
  • Last Modified:

Closing Parent Frame Window

Hi,

I have created an ASP page containing 3 frames, say left,middle & right . User is entering some data in middle frames and to save pressing save button and i m redirecting user to the next page. If the details are saved i m giving successful message to user using window.alert.

Now I want to close the main browser(frame) window as soon as the user presses OK button. Pls help me..

regards,
Pankaj Bhatnagar
0
bhatnagarp
Asked:
bhatnagarp
1 Solution
 
CyberGhostCommented:
As far as I know there is no way to close parent window without showing a prompt with question if really close MSIE window to user. If you open a child window, it can be closed without this prompt.

For close opened window you can use:

<script language="JavaScript">
<!--
test=window.open('test.html');
//-->
</script>

<input type=button value="CLOSE" onClick="test.close()">

regards
0
 
niteshnCommented:
window.close(), self.close() functions can be used to close the windows. But if the window being closed is an instance opened by the user, he will be prompted whether he actually wants to close the window or not. The basic funda is that you may close those windows thru javascript opened by you (using javascript)
0
 
Sashi RachabattulaSCRUM Master, .NET Project LeadCommented:
here u r call this function

<script>
function closetop()
{
top.window.close()
}
</script>
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
CyberGhostCommented:
But that will always bring that prompt as I said.

This is from http://developer.netscape.com/docs/manuals/communicator/jsref/index.htm ...



close
Closes the specified window.
Method of
 Window
 
Implemented in
 Navigator 2.0: closes any window.
Navigator 3.0: closes only windows opened by JavaScript.
Navigator 4.0: must use signed scripts to unconditionally close a window.
 



Syntax
close()
Parameters
None

Security
Navigator 4.0: To unconditionally close a window, you need the UniversalBrowserWrite privilege. For information on security in Navigator 4.0, see Chapter 7, "JavaScript Security," in the JavaScript Guide.

Description
The close method closes the specified window. If you call close without specifying a windowReference, JavaScript closes the current window.
The close method closes only windows opened by JavaScript using the open method. If you attempt to close any other window, a confirm is generated, which lets the user choose whether the window closes. This is a security feature to prevent "mail bombs" containing self.close(). However, if the window has only one document (the current one) in its session history, the close is allowed without any confirm. This is a special case for one-off windows that need to open other windows and then dispose of themselves.

In event handlers, you must specify window.close() instead of simply using close(). Due to the scoping of static objects in JavaScript, a call to close() without specifying an object name is equivalent to document.close().


Examples
Example 1. Any of the following examples closes the current window:

window.close()self.close()close()
Example 2: Close the main browser window. The following code closes the main browser window.

top.opener.close()
Example 3. The following example closes the messageWin window:

messageWin.close()
This example assumes that the window was opened in a manner similar to the following:

messageWin=window.open("")
0
 
sbdidineCommented:
you can try parent.close()
I know it works for parent.location.assign("newPage.html") so maybe...
0
 
CyberGhostCommented:
I've tried that. It does raise the prompt. Think there is no way to "hack" it.

regards
0
 
CyberGhostCommented:
I've tried that. It does raise the prompt. Think there is no way to "hack" it.

... by the way that parent.location.assign("newPage.html") has done endless loop with that prompt so maybe that could be a way to provoke into closing it. Or to not visit that site again ;o)

regards
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now