I'm trying to trigger a popup on initial page load (based on certain conditions). The purpose being for oauth authentication. I have everything working through a button click, but for some reason when trying to open the popup using a useEffect, I run into the issue where the window.opener is null and therefore cannot callback.
I have made a minimal demo here outlining the issue. Immediately upon loading, it should attempt to open a popup automatically. If you allow it, and then run window.opener in the console of the popup, you'll see that it is null
However, pressing on either button (direct or through the same use useEffect via a state dependency) the window will open again and the opener will no longer be null.
https://codesandbox.io/s/condescending-shannon-t0xjo
Perhaps you browser is blocking popups as it is not an user initialised event?
Related
I'm facing a problem like this:
I've an HTML page , when I click a button it triggers a job on the backend server, the status on the page keeps getting refreshed and when it reaches a certain state a new window is opened through JS logic :
if (status) {
window.open(URL, "_blank");
}
Now, my problem is if this page is open on multiple browsers, or even multiple instances of same browser, the window.open() is triggered across all of them when the status is true.
Is there a way to make the window open only from the page or browser session from where the job was triggered? Please help.
I'm wondering how to logout properly through the oidc-client UserManager signoutPopup method, without throwing an error when the user closes the popup window?
I'm calling UserManager's signoutPopup method and a popup window opens telling me that I've been logged out and I'm also presented with a link back to the application. Up until now everything works as expected.
Now, if I follow the above link, the application is loaded into the same window. Regardless whether I follow the link first, or close the window immediately there's an error
'Popup window closed'.
When the popup window is opened UserManager starts a timer that throws the above error if the window is closed before being cleaned up. I'm guessing that I'm supposed to clean it up somehow. Maybe, I'm just supposed to catch the error.
Does anybody know how logout with the signoutPopup method is supposed to work? I haven't been able to find any documentation or examples regarding this.
I'm using oidc-client 1.2.2, Angular 2 and IdentityServer 3.
I am noticing that my share popups are being blocked on our application but not others.
Here is the code execution:
1.) User enters web page.
2.) User clicks on facebook or twitter or googleplus share icon
3.) Onclick event passes the request to an internal controller that saves some information and then redirects back to the originating webpage. This time, however, there is a request parameter that invokes the usage of opening a new window.
The code I have that invokes opening a new window is (for this example we will use facebook):
var url = 'https://www.facebook.com/sharer/sharer.php?u='+copyLink;
window.open(url,'newwindow','width=600,height=600');
Now, if i enable popups it works fine. The problem is the user has to enable popups every time.
Is it a server issue? What is the reason why on other apps they don't have blocked popups but for OUR APP we cannot use popups without enabling popups
Any help would be greatly appreciated.
From what I understand, your application attempts to open a popup window following a page load. The nytimes.com popup appeared in response to a mouse click.
There is an important difference between these two ways to open a popup: the latter follows a user-initiated action but the former does not. As a result, popup blockers will generally block the former but not the latter. A lot of users wouldn't be too surprised if a popup opened when they clicked a button, but they would be more irritated if a popup appeared when a page loaded. The fact that your popup was ultimately triggered by an action on another page doesn't matter - what happens if you manually add to the URL the extra parameter that opens the popup?
Here's an old page on MSDN on popup blockers. It may describe the popup blocker in IE6 (of all browsers), but I think it still provides a reasonable explanation of when popup blockers typically permit or block popups.
Would it be possible to open a popup for your share dialog before calling back to the server? I would expect that opening a popup in the onclick handler would work without needing to explicitly allow popups.
I am using FuncUnit to test a small application I wrote. I have a button that will open a popup window (using the JavaScript function window.open(...)). I can get FuncUnit to press the button and open the pop up window,but I'm not sure how to proceed in order to get a handle on the popup window and do further testing.
Unfortunately, I cannot change any of the code in the pop up,
Thank you,
Matt
open returns a reference to the created window's window object. So you can simply use that to access anything in the window. Not sure if you can verify that it has finished loading if you can't modify the popup. Also note that both windows must be on the same domain in order for you to access it.
I am working on a small extension for personal consumption and practice. What I would like to do is provide some information every time Firefox starts using a modal dialog. I know this is generally frowned upon, but this is mostly for know-how. I have a few question regarding some things---I feel like there are better ways to do them. Kindly share your wisdom:
I have created a small dialog XUL, and I have an event listener registered to the load event of the main window. To actually display the dialog, I use:
window.openDialog("chrome://myext/content/prompt.xul", "dialogname",
"chrome,dialog,modal,centerscreen,resizable", params).focus();
Problem 1: I can never get the start up dialog to be on the center screen (even if I have centerscreen enabled), it starts top left---it would be nice to have it in the middle---something like Firefox's password-on-startup request. How can I achieve that?
I would like the modal window to open only once per session, even if there are multiple instances of Firefox. What I have done to accomplish that is, once the dialog runs, I set an extension preference, and I check that before opening another dialog on the "load" event of any new window.
Problem 2: To make sure I somehow don't have preferences set from a previous session, I try to check if this is the first window opened, and if so, I reset the preferences. Just to be safe, I also reset them on the unload event of the last window that closes. To discover the first/last load and unload, I use the nsIWindowWatcher service, and see if I can traverse the returned enumerator:
var ww = Components.classes["#mozilla.org/embedcomp/window-watcher;1"]
.getService(Components.interfaces.nsIWindowWatcher);
var en = ww.getWindowEnumerator();
var win1 = en.getNext();
//if there is no more en.getNext(), then this is the 1st window
There has to be a better way to do this, no? Some event which only fires once per session (not per window) for example?
If the dialog box is cancelled, I want Firefox to close down. Right now, I accomplish that through a simple window.close() associated with the cancel button of the dialog. However, since the original load (which triggered the modal dialog) is called after the page finishes loading, I can see a small glimpse of the homepage before it closes due to window.close()---this is not elegant. Is there an event similar to "before_page_load"? What is the proper way to accomplish this goal.
Once again, this is mostly for personal use, so kindly ignore the usability factor of a startup modal dialog.
You probably need to observe the final-ui-startup notification, which happens before the main window opens. You do this by registering a component to observe the profile-after-change notification, then during that notification, add yourself to observe the final-ui-startup notification. When your component subsequently receives that notification, it can then open your modal dialog and subsequently quit the application if necessary.