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>
Related
I have an iframe within an iframe. So Iframe-2 is within Iframe-1.
How do I link from iframe-2 to iframe-1 without going all the way out to parent window and then clicking to reopening iframe-1?
window.parent.location.href = \"target_link";
I have a Parent window that displays information, including a link to open a Child window to edit the same information. I want to be able to either refresh the Parent window or activate a button on the Parent to re-select the data, when the Child window is being closed. Both programs are written in PHP.
The Parent program opens the Child window using the following JavaScript function:
function windowOpen(loadURL) {
// In order to allow JavaScript to Close the Window, the Windows needs to be
// opened with JavaScript. The URL to be loaded into the new Window is passed
// as a parameter.
window.open(loadURL, "_blank");
}
The Child program currently uses this JavaScript function to close itself:
function windowClose() {
window.open('','_parent','');
window.close();
}
How do I change the windowClose() function to either: i) Refresh the Parent window; or ii) click a button on the Parent page that will re-select and re-display the page.
Thank you in advance.
It's not clear what you are trying to achieve but try
cross window communication
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
Trying to open a link in a framed page and close the child window. The link bellow is in a child window and when I click it opens the link in the framed page, but did not close the child window
<a target="Resultado" href="?Tela=1"
onClick="javascript:return confirm('TryMe');window.close();">
I have used a code like this to close the window... but couldn't get it to work with the above code.
<a href="javascript:window.opener='Resultado';window.close();">
Try this:
<a target="Resultado" href="?Tela=1" onclick="clickHandler(event, this);">Link</a>
And declare this:
function clickHandler(e, el) {
var choice = confirm('TryMe');
if (!choice) {
e.preventDefault();
}
window.close();
}
I wasn't sure of your original use of window.close() since it came after the return and would never execute, so it's up to you to move it to where you want.
Create another webpage on your webserver & use that as the Custom URL thankyou page for your form.
In that new webpage have just one line of code.
<body onload="javascript:window.opener.childClosed();window.close();">
--
That code will call a javascript function in the parent window and then close the child popup; you can then use that javascript function to do a redirect on your parent page.
I am not to sure where the URL of your 'Thank you for requesting...' page is, but here is some javascript to redirect to google on your parent page after the form is submitted.
function childClosed() {
window.location = "http://www.google.com/"
}
You can put that script before your closing <body> tag.
--
Hopefully I have understood your query OK, let me know if you have any questions or need any clarification on this possible solution.
-
I have made a very basic clone of your webpage & form here if you want to test out the functionality, 'Factoring Question?' is the link that contains this code.
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