I have my web app with two popup windows parent and child
Sometimes the child popup can be opened directly from the main application
when user open the child popup from the parent popup, I would like to close the parent popup (if the child was called from the main application then close nothing)
So the parent code to open the child popup looks like so:
the window.open then window.close(); to close the parent
The reason my code is in a table on click because its a fancy button.
<TABLE id="openChild" class="clsButton" cellpadding=0 cellspacing=0 width="31px"
onclick="window.open('www.google.com','child title','width=950,height=500');window.close();" onselectstart="return false;" ondblclickFunc="" stateful="false">
table content
</TABLE>
For some reason this closes both parent and child
Any idea why?
Related
I have one html page (static html). Inside that I have anchor tag (.windowOpener), and a hidden div(.status) which shows the status. When user clicks the anchor tag, a window gets opened:
Click here
<div class='status' style='display:none'>Successful</div>
On click of this link, a separate window gets opened. In this new window, there is one link as
<a class='paymentButton' href='javascript:void(0)'>Do the payment</a>
Now on click of this anchor tag (.paymentButton), I want to close the new window and want to make the 'status' div visible in the first window. I don't want to use the modals.
Is it possible to do this? Any help will be appreciated...
Thank you in advance.
Use window.parent to access the parent window:
$(document).on('click', '.paymentButton', function() {
parent.showStatusDiv();
});
And declare showStatusDiv() function in the parent window:
function showStatusDiv() {
$('.status').show();
}
NOTE
In case of more that one level of windows, use window.top to access the top most window
I have child window which has a hyperlink. On click of hyperlink i have to redirect to parent window. I could do this using following syntax-
<a target="main" href='${pageContext.request.contextPath}/xyz/abc.jsp?id=123'/>
Suppose i have two parent window (P1 and P2) with two different session (S1 and S2 respectively) open. If i try to open child window from P2 and click on hyperlink, it redirects to P1 window. This behavior is very inconsistent. How can i ensure that hyperlink on each child window updates to their respective parent window ?
A popup is fired from an iframe. Inside this popup im trying to link the user to new page, this page should open on new tab on the parent, but for the popup the parent in this case is the iframe and not the container of the iframe (the parent of the iframe) where im actually want to open a new tab.
Is this possible? If not, how can I open the link on a new browser windows?
So far I tried this but is not working:
<button onclick="parent.window.open=('http://mysite.com/app_dev.php/gifts','_blank')" class="btn btn-primary">Altri Regali »</button>
Try instead
<button onclick="window.open('http://mysite.com/app_dev.php/gifts','_blank')" class="btn btn-primary">Altri Regali »</button>
Fiddle here
I want to show a child window which will perform some action and it will set to the parent window. The time when child window is open , parent window should be disable.
I tried this which return child window but parent window still in working mode while child window is open...
<a href="AddChoice" onclick="var x = window.open('url',,'','hemenubar=yes,height= 300,
width = 500,,scrollbars=no,dialog=yes,minimize=no,maximize=no,
alwaystop=yes,copyhistory= no,resizable=yes,toolbar=no,directories=no
,location=no,menubar=no,status=no,left=0,top=0');return false;">
Change Dependent Question...</a>
//This link returns a child window
You should use a modal dialog box. there are many ways to do that.
you can use some existing plug-ins.
jquery: http://www.designlabelblog.com/2009/03/20-ways-to-create-javascript-modal.html
YUI: http://yuilibrary.com/yui/docs/panel/panel-form.html
I'd like to provide a button on my child page that would close the child page from the child page itself. To make matters worse, I didn't write the child page - it is written using frames. So far I've tried this code in the child page:
Window.opener.location= '/parent page.html';
Window.close();
And, in the body:
close
HELP!
As the link you inserted is inside an iframe, use window.top.close() instead of window.close(). window.top will refer to child window you created.
HTML for your hyperlink will be
close window
This is cheating, but by refreshing the parent window the child window gets closed. Not very elegant but it works.
<form METHOD=post><p align=right><input TYPE="button" VALUE="Close This Window"onClick="window.parent.location.reload();"></p></form>