Close window using JavaScript - javascript

I have a window(1) that has a button(1). If I click on the button, then another window(2) will appear. It also has a button(2). If I click on the button (2) then popup will appear. How can I close the window(2) if I press "OK" on the popup window? I am using javascript.

// store reference to window
var window2 = window.open(...);
// close window via reference, put this in your OK button handler
window2.close();

Read here about window management.
You cannot do it according the security assurance of browser, there
are some action which doesn't allow to be managed directly via
javascript without user interference.
Got this from here /stackoverflow/

Related

JavaScript simulate physical click on a link to bypass pop blocker(Not Jquery)

I am opening a popup after main window load.
Problem:
When user actually click on link the popup opens without complaining anything.
But when I am using Javascript call to click on href, I am getting popup blocker.
I am suspecting that, browser identifies that, popup is opening without any actual operation by user and that's why it is blocking popup.
In herf, I am calling a javascript method to open the popup.
I searched all the questions regarding opening popup and simulating the click like this, these works fine to simulate the click but still getting popup blocker.
Is there any workaround to fool browser?
You can't fool the browser per-se in this scenario. You could however, launch a div as an overlay on the main window if that's an option.

Pop up window getting replaced if opened from another session

In Java web application (JSF), I have a Person form which has Add details button on click of this button, i'm opening a pop up window using java script but i haven't closed this pop up window yet. Now if i open a another session of the same application and try to add details for another person, it replaces the pop up window which was opened with previous session. How to avoid such scenario ?
var url = contextpath+'person/AddDetails.jsp';
var modalprops = "height=310,width=400,scrollbars=on,status=no;menubar=no,resizable=no";
window.open(url, 'adddetails', modalprops, false);
I'm not good at UI technologies :(, hence this question.
Give each window a unique name instead of having them all be called "adddetails".

close pop up window and redirect to parent window in struts2

I have pop up window , in which to upload an excel file of adding new users.
After clicking the button and successfully added the users into DB, I want to close the pop up window and refresh the parent window to see the updates. In Parent Window, it shows the list of users.
How can I handle all of these events and steps in Struts2 and javascript?
function callAddUsers() {
document.frmUpload.action = "addUsers.action";
document.frmUpload.submit();
}
I want to display some messages of how many users added in parent window too. How can I pass all those info by action?
Now the problem is when I successfully uploaded and added users, the popup window displays the list of users and I have two window opened.
Thanks.
Simple solution.
just window.close(); the popup window and target="main" , in here just target name of the parent window. all works perfectly :)

closing the current popup window on button click in apex using salesforce

i am in a strange situation
I have an apex page
inside that page there is a button on the click of which i call a a javascript method.
From this method i call window.open(url) and open a new popup window.
Now this new window is also an apex page.
This window contains a button.on the click of this button i want to close the current popup window using javascript.
can anybody suggest me what should i do?
i have tried:
**
window.close();
self.close();
**
I have tried with apex command button as well as with the HTML button.
but still window cant be closed.
Perhaps same issue as this: In Visualforce pages, is it possible to use the command line in the Firebug console?
So try disabling development mode on your user.
Søren

How to close parent window on child window open using window.open()

Using javascript "window.close()" method after opening new window using "window.open", it serve the problem i.e. but it will ask a confirmation message to user whether he really wants to close the window or not... if user selects yes then the parent window will close and if not then he will remain on the same window and new window will not get open up..
So is there any way so that parent window will get closed without asking any confirmation message and new window will gets open up ?
No. It´s a security feature. You are trying to manipulate an application on another users machine.
If you put it in another context it becomes clear why it is as it is and why it should be that way: Would you like if your email client suddenly closed cause you read an email?
EDIT: What you can do is having the login window trigger a navigate event in it´s opener so the first page gets replaced by the billing info page. Then it can close itself.

Categories

Resources