Is it possible to close specific pop-up window when other page is clicked using javascript? Something like below...
function closePopUp()
{
window.close('popup.aspx');
}
Thanks in advance.
if you open a pop with a name then it is possible
var popUp;
function OpenPopUp() {
//popUp is the name of the window
popUp = window.open("Yourpage", "something", "width=550,height=170");
}
Then you can close it as follows
function closeit() {
//closing a popup with name popUp
popUp.close();
}
OnClientClick="javascript:window.close()"
Related
Basically, I want the current browser tab to be closed on a click of a button. How do I implement this in ReactJS? Tried window.close() but did not work.
For security purposes, JavaScript can't close a window that it didn't directly open.
https://developer.mozilla.org/en-US/docs/Web/API/Window/close
As you can see from the example, the originating script (which opened the window) must also be the script that closes the window. A new window isn't capable of closing itself via JavaScript.
//Global var to store a reference to the opened window
var openedWindow;
function openWindow() {
openedWindow = window.open('moreinfo.htm');
}
function closeOpenedWindow() {
openedWindow.close();
}
On your click event handler, try this :
window.open("", "_self");
window.close();
I had opened a popup window from a modal now I need to refresh the page where my modal is by closing popup window or by a close button i had tried writing some codes i found here but not working some of my codes are
//this is not working
function closeAndRefresh(){
opener.location.reload();
window.close();
}
Call below function on onClose popup/onclick close button
function closeAndRefresh() {
location.reload();
}
function closeAndRefresh() {
window.top.location.reload();
}
I have a modal popup with custom page in Nativescript. I am calling open popup as below
var modalPageModule = 'components/appointmentDetails/tabs/location/location';
var context = args.context;
var fullscreen = false;
page.showModal(modalPageModule, context, function closeCallback(location, address) {
}, fullscreen);
On popup i have a close button from where modal popup should be closed.
But from the reference site i could not find anything helpful method to close modal popup.
Thanks in advance.
There is function closeModal() in page module. Just:
page.closeModal();
Reference: here
I have made a popup window with a button that's supposed to close the window. However, it does not work. Here is the code:
winpopup.document.write(<INPUT TYPE = "BUTTON" Value = "Close Window" onClick = "closeWindow();">)
function closeWindow(){
winpopup.close();
}
Winpopup doesn't have closeWindow() method. Use opener's.
function closeWindow(){
opener.winpopup.close();
}
I am having 2 pop up screens in my (Main) jsp.
In the first pop-up the user will update the required information(Update) and after submitting the info, a new pop up will be shown that shows the modifications(View).
I would like to refresh the Main page when the user clicks on the close "X" in the view page.
I tried to use some scripts like the following in the view page, but it did not work:
<script language="JavaScript">
function refreshParent() {
window.opener.location.href = window.opener.location.href;
if (window.opener.progressWindow)
{
window.opener.progressWindow.close()
}
window.close();
}
</script>
Try putting this javascript code in your popup window:
window.onunload = function(){
window.opener.location.reload();
};
function ref_and_close()
{
opener.location.reload();
self.close();
}
//just call the function
ref_and_close();