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.
Related
I am trying reopen the existing window from different windows
For example ,
Inside window one, I am opening page one and on that page I have button, upon on click of that button I am opening another window with the name "Connect" using following code
var connectWin = window.open("url to Connect page","Connect", "status=no,toolbar=no,menubar=no,location=no,directories=no,top=0,left=900,width=800,height=750");
connectWin.name="Connect";
Now, in the same window one, I am traversing to different page (within same domain) and on this page I have another button and upon on click I am checking whether connect window is already open or not if yes, then I open the existing window otherwise thow an error
// code to take reference of an existing connect window
var connectWnd = window.open('', 'Connect');
if( jQuery.type(connectWnd) === "undefined" || connectWnd.location.href === 'about:blank' ){
connectWnd.close();
$("#errorMessage").text("Connect page is not opened yet");
}else{
//if connect is already open then post a message to that window
connectWnd.postMessage(data);
}
The issue that i am facing is , if user open another page in a different window than I alway get Connect Page is not opened yet error.
It seems when user tries to access the page from different window i.e. window two than in that case window.open('', 'Connect'); fails. So is there a way to open an existing window from any window in the browser.
There is no way to get access to other windows the user has opened in his browser from a web page since that can cause serious security issues. Also, it is impossible to redirect to another tab in the browser from one page (unless it is opened with window.open) since it has been abused by ad networks to force the browser to the other tab (earlier you could use alert() to force navigate the user to another tab)
The best solution to cover all edge cases may be to develop a browser extension and synchronize actions with a server to register open tabs (but even in that case, you cannot redirect him to a window on another browser!)
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".
i have three links in my page, i want to restrict the user to open a link one at a time. So how to check through javascript when user clicks on a link whether it has been opened already a window or not(by opened i mean not just click the link and close it, the window should be opened at the time when user clicks on link).
Give the windows a name, then you can access them using the DOM. Every time a user opens a new popup window you could run a loop that will try and access all the popups. If another window is open already you can stop the current popup event from happening.
The popups would all have to be under your domain for this to work.
My site opens up a popup window to an external site, but at some point, the popup window will redirect to my site again. Because of security reasons, I know I can't look at the popup window URL until it redirects to back to my site. What I did is kept checking every second to see whether I could access the url address, and once I could, (meaning the popup window was back on my site) I stored the Url info and closed the popup. This seems like a pretty bad way of doing it...
Is there any way to detect the window returning to my site?
If you have control over the linkback page for the popup then you can set up a special page just for this purpose. All you'd need to do would be to create a page with some javascript that runs to notify you that you have come full circle.
One property that popup windows have is the window.opener property which refers to the parent window that initially created the pop-up.
This should be a good place to start.
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 :)