From pop window active the parent window - javascript

Using JavaScript I open the pop window and parent window is inactive at this time,
I wanted to active parentwindow through popwindow. (this is a web project on Java)

You can usually window.opener in JavaScript to get at the window that opened at popup.

Related

How know if a window can be closed with js

So as it has been discussed elsewhere, a window can be closed by js using window.close() only if it has been opened by a script.
I have a page that offers a button to open a discussion window. The discussion window opens to a new tab with window.open(). The discussion page has a button that calls window.close(), which closes the discussion window and takes you back to previous tab, so you can continue from where you left off.
The problem is that if someone takes a the url directly to the discussion window, the close button does not work.
Is there a way to detect if the window will be closable with window.close(), so I can show the button only if it will work?
You can check to see if window.opener is not null:
When a window is opened from another window, it maintains a reference
to that first window as window.opener. If the current window has no
opener, this method returns NULL. Windows Phone browser does not
support window.opener. It is also not supported in IE if the opener
is in a different security zone.
You can try using the window.opener object, which returns a reference to the window that opened the current window (if it's another window), or NULL if the current window was not opened via JS.
if (window.opener) //Show button

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.

Control a pop-up window status

IS there a way in Javascript to control the status of an open pop-up window?
I open the pop-up window with javascript and I need to close it at a certain point, specifically when the URL of that pop-up window contains these parameters:
oauth_token
and
oauth_verifier
ie: http://mysite.com.com/dev/uspolitics_pulse/functions.php?oauth_token=XX184mmCiV1Vp5EXNAdswiwrOUrZBkGx7bAdE0UwCTU&oauth_verifier=rIJJPdAPFzXQFsNvZufdSKTZdImGxSgyN7xKgNZz644
The function open returns the window object of the pop-up window.
That object has a method called close that can be used to close the pop-up window. It has the same properties as the global window object like location that can be used to get the URL.

About Popup window data to Parent window

I am opening one Popup window on Button Click in main window, it is for Image Uploading.
when I am uploading Image , i.e. on Upload button click I am closing this Popup window and opening new Popup window.
And Now I want to display the Popup data to Parent window without refreshing, But I am not getting Parent window object.
i.e. window.opener or window.parent. Please give me help. How I will get Parent window object?
you can try this,
When first popup window is opened(uploading image window) get parent window object for this popup and store in some variable(java script variable ) like this
var parentWindowObject=window.opener;
Try passing this object variable to the second pop up window( on upload click) and in this page you will get it main page window reference (parentWindowObject) and using this you can fire new request to main page to post your required data as follows
parentWindowObject.location="your request";
Reason for not using window.opener in second popup
As you are opening a new popup from the present popup. The parent for the newpopup will be the popup which you are opening from here is your upload popup and you are closing the upload popup once you click on upload so for the new popup the value for window.opener(a reference for the parent window) will be null.
You can access the parent window by using window.opener
See window.opener
which returns a reference to the window that opened this current window. When a window is opened from another window, it maintains a reference to that first window as window.opener. If the current window has no opener, this method returns NULL.

What's different when a page is opened by window.showModalDialog?

Anyone knows the difference?
The problem I met is that the page stops working correctly when opened by window.showModalDialog
window.showModalDialog vs window.open
Window.open will open up a new window through Javascript, with the URL and other features of the window that u pass as parameters. Here the parent window which opens the new window and the child window are independent windows.
Eg. Below
`window.open('winOpen.htm','name','height=255,width=250,toolbar=no,directories=no,status=no,
linemenubar=no,scrollbars=no,resizable=no');`
Window.showModalDialogue again works smilar to a window.open only diffrence being its a Modal window, It opens up as a new window but doesnt allow the user to access the parent window, unless you explicitly close it.
Here the child window is dependent on the parent window. If you close the parent window the child would also get closed.
window.showModalDialog("xpopupex.htm","name","dialogWidth:255px;dialogHeight:250px");
ShowModalDialogue windows can be used when u want the user to perform a particular action in the new window before he access the parent window again. like login before he can access the parent page..
tryed to make it as simple as possible...hope this help.. ;)

Categories