Windows opener is null

window.opener is null, parent window cannot access its own popup, or JavaScript runtime error 0x800706b5 (facebook, twitter login or paypal payments)

After sinking a lot of time into this issue, I want to make the solution searchable for anyone else who encounters the same problem.

Common use scenario

  • You want to implement external authentication with a provider such as Twitter, Facebook, Microsoft, GitHub, or any other site that supports OAuth; or
  • You want to implement external payment with a provider such as Braintree, Paypal, etc.
  • You are already using a server-side OAuth library, for example Owin with NuGet package(s) to support Twitter and Facebook, as in ASP.net projects generated with the New Project wizard. You might also be using another library, or developing in another MVC ecosystem like Ruby or Node.js/React.
  • You want to open a window to perform authentication and close that window when it succeeds or fails, instead of redirecting the user out of your site temporarily. Since your site is a Single Page Application, redirecting the entire view ruins the user experience.
  • You are testing all this from localhost, by having your run action open localhost:port. Also, you are using IE or Edge as the browser.

Symptoms

You wire up «Login with XXX» button to execute JavaScript that opens a new window with a GET request to your external login controller which then sends a 302 redirect to external login provider’s OAuth endpoint with OAuth information attached («challenge» step).

Читайте также:  Чем открыть файл mobi windows

At this point, attempting to access the popup window from the parent window will throw JS error 0x800706b5 (object has been disposed or no longer available). This is OK, because the window no longer belongs to us, until it redirects back to our site. We handle this edge case with try/catch and eat exceptions until it becomes available again.

User authorizes your app (a POST to external provider) and provider redirects back to your site. Alternatively, provider detected that user is already signed in & approved the app so it redirects back to your site. In either case. popup is back in your zone, with a GET processed by one of your controllers.

Problem

The page from your site that’s inside the popup cannot access it’s opener because it’s now null. If you attempted a work-around by instead having its parent store a reference and keep checking that reference inside of a try block, the reference does NOT become valid after the popup URI is back to your domain. If you uploaded your site to the server, this would work and the reference would become valid, allowing parent to check a window variable set by the child (such as requestingClose) and call close() to close the child.

window.opener is NULL with right click on link

I’m using the javascript window.opener property to refresh the parent window in the child window.

The parent window cointains just a table with data and a link to the child window, when the child window is opened then executes a js function in the parent using the window.opener property, the js function in the parent refresh the table using ajax.

Читайте также:  Windows 10 создаем папку temp

The problem is with window.opener because is NULL when the user open the link using the right click (contextmenu).

parent.jsp

child.jsp

2 Answers 2

Ok I know it is late but I leave this here for future use

to the target=»_blank» link

The opener will be passed through the child page

In the following cases, the browser does not populate window.opener, but leaves it null:

The opener can be omitted by specifying rel=noopener on a link, or passing noopener in the windowFeatures parameter.

From Firefox 79, windows opened because of links with a target of _blank don’t get an opener, unless explicitly requested with rel=opener.

Having a Cross-Origin-Opener-Policy header with a value of same-origin prevents setting opener. Since the new window is loaded in a different browsing context, it won’t have a reference to the opening window.

sidenote: btw there is no difference if you open a page with right or left click

window.opener is null or not an object

Thank you for using Vista Support forum,

We going to need some more information from you to properly diagnose your problem.

Is this a home computer or work computer? Does it connect to a network with a server/domain?

What is the operating system? XP or Vista? 32 bit or 64 bit?

What version of Internet Explorer are you using?

Are you running any antivirus/antimalware program on your computer? Are they up to date?

Did you install updates available from Windows Update?
You said you installed some update and there was errors, what is the updates you installed and what is the errors say?
If you are sure the updates causing the problem, try to run System Restore to go back a few days before the update were installed

Читайте также:  Windows search download windows 10

Running the System Restore utility…

1. Click Start , click All Programs , click Accessories , click System Tools , and then click System Restore .

2. Click Continue or provide Administrator credentials if necessary.

3. Click Choose a different restore point , and then click Next .

4. Select a Date and Time prior to first sign of the issue you’ve described.

5. If the date you need is in excess of (5) days click the Show restore points older than 5 days check box.

Important Notice : That System Restore affects Windows system files, programs, and registry settings. It can also make changes to scripts, batch files, and other types of executable files on your computer. Thus, any recently installed programs, updates, or changes to configuration will be lost if you use System Restore. However, make note that System Restore does not affect personal files, such as e-mail, documents, or photos, so it cannot help you restore a deleted file.

If it is just the website and you are using IE 8, try Compatibility View and no addons mode.

IE8 COMPATIBILITY VIEW

HOW TO RUN IE8 WITHOUT ADD ONS

One way to open is to navigate to start menu-> All Programs-> Accessories-> System Tools-> Internet Explorer (no Add-ons)

Another way is Windows key + R key which opens Run command, type iexplore –extoff and this will open up IE8 without add-ons.

This opens up IE without ActiveX controls and browser extensions.

Hope this helps,

Kevin
Microsoft Answers Support Engineer
Visit our Microsoft Answers Feedback Forum and let us know what you think.

Оцените статью