Hi,

I need an answer to a problem with iframe below.
I have an iframe jsp page which is a popup window from an other jsp page.
The iframe jsp popup window has few buttons.
I need the return reponse of button clicked from iframe in parent window.
BTW the parent window is not an iframe.

Could you please get me a solution for this?

thanks.

Amar.

Hi,

you can access the parent window with the opener or the parent property:
- if a document opens a page in a new browser window (for example, by an anchor element or the open method), then the opener property can be used in the child document to access the parent window object.
- if the current document is within a frame or iframe and you need the window that hosts the current window, use the parent property.

Example for frames:

in the parent window:

<script>
	function OnFrameButtonClick () {
		alert ("You clicked on a button in the frame");
	}
</script>

in the child frame window:

<head>
    <script>
        function OnButtonClick () {
				// check whether the parent window and the OnFrameButtonClick method exist
			if (window.parent && parent.OnFrameButtonClick) {
				parent.OnFrameButtonClick ();
			}
		}
	</script>
</head> 
<body>
	<button onclick="OnButtonClick ()">Test</button>
</body>

You can find further examples on the following sites:
opener property,
parent property.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.