How to close modal popup? - javascript

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

Related

how to make a button on a popup window that closes that popup window

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();
}

How do I make this window close automaticly after a button is clicked in javascript?

I have this button made in javascript and when it is clicked it opens up a small twitter popup window that allows the user to follow me. Now what I want is for this popup window to close once the person clicks "Follow". I have attached a picture of the popup window so you can get more of an idea. Here is the script for that window that i'm trying to modify.
<script type="text/javascript" charset="utf-8">
window.onload=function(){
twttr.events.bind('follow', function(event) {
var followed_user_id = event.data.user_id;
var followed_screen_name = event.data.screen_name;
//alert('you have followed " '+followed_screen_name+'"');// Uncomment it for the javascript popup to activate
document.getElementById('download').style.display = 'block';
});
twttr.events.bind('unfollow', function(event) {
//alert('Unfollowed now'); // Uncomment it for the javascript popup to activate
document.getElementById('download').style.display = 'none';
});
}
</script>
I don't know how or where to insert the code that makes it close once the follow button is clicked. If you are familiar with this situation I would greatly appreciate any information whatsoever. Thanks in advance :)

How to close specific pop-up window in asp.net using javascript?

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()"

Not able to redirect parent window to another page from modaldialog child window

My requirement is as mentioned below:
I have a modaldialog popup which I open using the following code:
window.showModalDialog('/test.jsp',window, 'center: yes; dialogHeight: 230px; dialogWidth: 550px; help: no;scroll:no;' );
I have a button in the modal dialog window which once clicked should close the popup and re-direct the parent window to login page.
I have tried the following:
var par = self.parent;
self.close();
par.location.replace("/login.jsp");
Now what is happening that modal dialog is getting closed but instead of redirecting the parent window to login page, a new window opens up and loads this page inside that.
Appreciated if somebody could please give me some idea about the issue?
Additional information:
My parent window is in frameset. To access parent's reference from child, normally window.opener is used but here in this case, I get this as undefined. Not sure why.
Answer:
window.close()
window.dialogArguments.location.href = "/login.jsp"
try using :
window.opener.location = url;
window.close();
try this
window.location.href = URL;
window.close();
window.close()
window.dialogArguments.location.href = "/login.jsp"

closing the current popup and redirecting to the parent window

In JS I am using :
window.open('index.php?module=Contacts&action=UD_lookupemailtemplates&tempmode=userdefined&temp_url='+encodeURIComponent(temp_php_url),'emailtemplate','top=100,left=200,height=400,width=500,resizable=yes,scrollbars=yes,menubar=no,addressbar=no,status=yes')
To open a small window which has few links.
Now on the click on any one link an id will be attached to the a url and then I used this :
window.document.location.href = url;
This is also in JS. what this does is that it changes the contents of the small popup window but I need it to close the popup window and open this url in the main parent window from where the popup was created. Is that possible ?
Suppose
var popup_window = window.open(...);
For closing this use
popup_window.close();
and to redirect the parent windows
window.parent.location.href = url;
To close a popup that you opened, store the return value from window.open:
var popup = window.open(...);
Then, you can use:
popup.close();
I'm not clear based on your question where the URL variable is stored (in which window), but you can reference window variables in the popup via popup.variableName.
First you have to redirect parent window using
window.opener.location.href = "http://url.com";
and than close the current (popup) window
window.close();
Personaly I don't like pop up windows instead of that maybe yo can do the following:
You can open an overlay DIV that you can populate with data from "index.php?module=Contacts..." using AJAX and make links inside of that DIV that way so that by clicking them you close that overlay DIV and redirect page to what you want...

Categories