how to make pop up window and parent window both active - javascript

I want to open a pop up window and submit data through it. But as soon as I click outside of this small window, this popup gets closed. I want that both the windows should be active.
Please help

Related

JavaScript - How to set focus to the Popup window

In JavaScript is there an option to point focus to an already opened Popup window?
Scenario:
In a web page, I click on a link in webpage1 to open a popup window. Now I want to fill up few details in the popup window using JavaScript followed by save and close the popup window.

Closing popup windows on click

I found this nifty popup window JavaScript code that I like over at How to Auto Popup a CSS3 Modal Window When Page Loads?
Problem is that I want the user to simply click away from the box and that would cause it to close.
I tired to use self.close () from http://www.javascript-coder.com/window-popup/javascript-window-close.phtml but I cant figure out how to apply to everything else around the box. So when the users clicks anything outside the box it will close the popup.
Along with that I want to make sure that when the user closes the popup that it does not return during their php session. So basically unless they close their browser and bring it up again it will remain closed.

How can I open a pop-up window without it being blocked?

I haven't found a single answer able to tell me what's the right way to open a popup.
Times have changed, and popups have been mostly replaced with fancybox-like boxes. However, there are still times when popups are needed.
For those cases, I don't want my popup to be blocked by the browsers.
What's the right way to open a popup without it being blocked? Even if it opens a new tab in the browser. I just want my popup to be open, and have control of it from the parent or vice versa.
Popup blockers will block any popup, unless it is opened because of an user action.
If the user clicks on a link, and a popup is opened in the click listener of that link, the popup blocker knows the user want to open something and will not (or should not) block the popup.
What you cannot do:
open a popup when the page is opened or closed
open a popup after a certain interval
open a popup after something asynchronous happens
What you can do:
open a popup in the on click listener
using target="_blank" in a anchor tag
You can access both windows with JavaScript variables:
if you use window.open, the parent can have a reference to the popup by assigning the result of window.open to a variable. Check out this article at W3Schools.
If the popup needs to have access to the window who has opened it, you can use window.opener. Check out this question.
try this, it works for me
$('#myButton').click(function () {
var redirectWindow = window.open('http://google.com', '_blank');
redirectWindow.location;
});
Js fiddle for this is here https://jsfiddle.net/safeeronline/70kdacL4/2/
if you want to open new tab after ajax call see this fiddle http://jsfiddle.net/safeeronline/70kdacL4/1/

Identify if the window opened is popup window or a normal window in IE

I have a requirement where i want to restrict users from opening url manually from browser. The url should only open from clicking a button which opens a pop window.
Notes:-1.) I cannot temper with button code that's application's standard code
2.) I have already tried window.opener but it does not work in IE.
So basically i want to identify if the opened window is a pop window or normal browser window.
Thanks in advance.

How can I get number of child windows for a browser

I have one icon (say open) in home page. When I click on this icon one child window will be open and the icon in that home page is also changed to 'close icon'. When close this popup window the icon should be same as previous icon (i.e. open icon) in home page. It's working fine when I stay on the same page.
But when redirecting from home page to next page the entire page gets reloaded. And the default image (open icon) is displaying even if the popup window is opened.
Now my requirement is:
At the time of page redirection the image should be loaded based upon the popup window. i.e. if popup window is open it should display the close icon otherwise it display open icon.
If page is refreshed or redirecting to another page the reference of the popup window is removed. then how can I get the reference of that popup window in a redirecting page.
How to count the number of child windows for a browser
EDIT:
I have tried the following solutions:
I set cookie at the time of opening a popup window and reset that cookie whenever I have closed that popup window. But the problem is, at the time of page redirection if I close the popup window the cookie is not reset to it's previous value, because the page is still in processing.
same problem with the session variable also
Please help me.
Set a cookie or a session variable when you open and close. This way you can remember the state of your popup window during new requests
When you go from one page to the next, you lose the reference to the pop-up window. But the pop-up window doesn't lose its reference to the main window. window.opener will always point to the window that opened it, even when there's a page change. Use this fact to reestablish communication between the windows after a navigation event. You might need to use an interval function to probe the main window, as I don't think you can listen for an event.

Categories