How to open Javascript popup from iframe window to parent window - javascript

I am working in jsp with javascript . Here i have use the iframe inside parent window. When i cliclk the button in iframe page the popup window will be opened inside iframe page. But i want to show the popup in parent window ? anybody help me.
Iframe look like in parent window:

USE:
myFrame.contentWindow.open()

Related

How to display modal window to overlapping the iframe?

Am trying to display a file in a modal window when a button in an iframe is clicked. The iframe is present in a main window and an iframe is also there where we have kept a button to view the file in a modal window.
The modal window is working fine, but it opens in the iframe itself, but i want that to come out of the iframe and get displayed as a modal window.
HTML and Javascript for the view button where the modal window is called in onClick()
<span class="btn" title='hh' onClick="window.parent.showModal('../sales_stock/stockForm.php',1160,600);">Add New Stock Statement</span>
the show modal function is responsible for poping up the modal window.
I want to know what i should do to make the modal window pop out of the iframe.
If your iframe content from the same domain as you page you can subscribe to the click event from the main page and show popup from the main page. You can't overlap iframe borders from inside.
On the main page:
$("#myframe").contents().find("#button-inside-of-iframe").click(function(){
$('#mypopup').show();
});

Close other HTML window by function

I need a popup window to appear to the user but without a parent window. However, I believe this to be impossible.
I think that I may have to make the popup close the parent after it appears, but how?
iI tried this in the popup:
<BODY align="center" valign="center" onload="javascript:window.opener='x';window.close();">
But it closed the popup window itself. How can I make the popup close its parent?
Try window.opener.close() instead.
Unless the "parent window" was opened with JavaScript itself, then that is not possible. JavaScript is only allowed to close windows it opened itself.

About Popup window data to Parent window

I am opening one Popup window on Button Click in main window, it is for Image Uploading.
when I am uploading Image , i.e. on Upload button click I am closing this Popup window and opening new Popup window.
And Now I want to display the Popup data to Parent window without refreshing, But I am not getting Parent window object.
i.e. window.opener or window.parent. Please give me help. How I will get Parent window object?
you can try this,
When first popup window is opened(uploading image window) get parent window object for this popup and store in some variable(java script variable ) like this
var parentWindowObject=window.opener;
Try passing this object variable to the second pop up window( on upload click) and in this page you will get it main page window reference (parentWindowObject) and using this you can fire new request to main page to post your required data as follows
parentWindowObject.location="your request";
Reason for not using window.opener in second popup
As you are opening a new popup from the present popup. The parent for the newpopup will be the popup which you are opening from here is your upload popup and you are closing the upload popup once you click on upload so for the new popup the value for window.opener(a reference for the parent window) will be null.
You can access the parent window by using window.opener
See window.opener
which returns a reference to the window that opened this current window. When a window is opened from another window, it maintains a reference to that first window as window.opener. If the current window has no opener, this method returns NULL.

What's different when a page is opened by window.showModalDialog?

Anyone knows the difference?
The problem I met is that the page stops working correctly when opened by window.showModalDialog
window.showModalDialog vs window.open
Window.open will open up a new window through Javascript, with the URL and other features of the window that u pass as parameters. Here the parent window which opens the new window and the child window are independent windows.
Eg. Below
`window.open('winOpen.htm','name','height=255,width=250,toolbar=no,directories=no,status=no,
linemenubar=no,scrollbars=no,resizable=no');`
Window.showModalDialogue again works smilar to a window.open only diffrence being its a Modal window, It opens up as a new window but doesnt allow the user to access the parent window, unless you explicitly close it.
Here the child window is dependent on the parent window. If you close the parent window the child would also get closed.
window.showModalDialog("xpopupex.htm","name","dialogWidth:255px;dialogHeight:250px");
ShowModalDialogue windows can be used when u want the user to perform a particular action in the new window before he access the parent window again. like login before he can access the parent page..
tryed to make it as simple as possible...hope this help.. ;)

From pop window active the parent window

Using JavaScript I open the pop window and parent window is inactive at this time,
I wanted to active parentwindow through popwindow. (this is a web project on Java)
You can usually window.opener in JavaScript to get at the window that opened at popup.

Categories