Reputation: 7815
I am using a JS popup window for an Oauth2 Implicit Grant. I'm using JS to monitor for URL changes to get the code grant.
newWindow.addEventListener('unload', function(e)
{
console.log(e.currentTarget.location);
if (e.currentTarget.location.href.includes('code='))
{
var url = new URL(e.currentTarget.location.href);
alert(url.searchParams.get('code'));
}
});
The problem I am having is that the location
field is giving two different values for the href
parameter.
As you can see in the image, the href parameter has two different values. How do I make sure I always get the second value?
Upvotes: 0
Views: 150
Reputation: 68933
The Location is evaluated some time before.
If you hover over the little blue i icon, it says:
Value below was evaluated just now.
Upvotes: 4