pythonista-webview icon indicating copy to clipboard operation
pythonista-webview copied to clipboard

ERROR: TypeError: null is not an object (evaluating 'popup.opener')

Open cvpe opened this issue 4 years ago • 16 comments

Hello Mikael

I use your module in my big script managing contacts of my neighbor who is radio-amateur. I get the error message: ERROR: TypeError: null is not an object (evaluating 'popup.opener') In a web page which opens a second tab in Safari: "href="Javascript:popupGraphic('ConfirmQSO.cfm?QSLID=782567761','',10,10,500,300)">Click here to Confirm this card"

Thanks for your needed help

cvpe avatar Apr 28 '20 11:04 cvpe

Just checking the basics: is Javascript with uppercase first letter same as ”javascript”?

holvi-mikael avatar Apr 28 '20 11:04 holvi-mikael

I did not change anything but thus popup works on a Mac and on Safari on iPad. Does WKWebView supports multiple tabs?

cvpe avatar Apr 28 '20 15:04 cvpe

Préférence javaScriptCanOpenWindowsAutomatically is False by default, is it not the reason?

Tried with True, same problem

cvpe avatar Apr 28 '20 16:04 cvpe

That works with SFSafariViewController instead of WKWebView

cvpe avatar Apr 28 '20 16:04 cvpe

No tabs. (You need to build the browser around the WKWebView yourself.)

holvi-mikael avatar Apr 28 '20 16:04 holvi-mikael

SFSafariViewController does not create a new tab but opens the popup window in the same tab. The previous page button returns to original page. No way like this?

cvpe avatar Apr 28 '20 16:04 cvpe

Need to look into it, but I find it unlikely since even js popups had to be implemented separately.

M

cvpe [email protected] kirjoitti 28.4.2020 kello 19.26:

 SFSafariViewController does not create a new tab but opens the popup window in the same tab. The previous page button returns to original page. No way like this?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

mikaelho avatar Apr 28 '20 16:04 mikaelho

Ok, Thanks anyway for this module.

cvpe avatar Apr 28 '20 17:04 cvpe

This does not look very promising: https://stackoverflow.com/questions/39070722/wkwebview-wont-open-social-media-login-popups/39073499#39073499

mikaelho avatar Apr 28 '20 17:04 mikaelho

I agree for the new tab but if you open the popup in the same, like SFSafariController does, it is ok

cvpe avatar Apr 28 '20 17:04 cvpe

Okey, reading into this, delegate probably needs to implement webview:createWebViewWithConfiguration:forNavigationAction:windowFeatures: where a new webview needs to be created and returned. Not sure what will happen if we just return the same webview, but can try that as well.

mikaelho avatar Apr 28 '20 20:04 mikaelho

In reality, my script logs to eQSL.com site of radio amateurs. But, this is not a big issue. My neighbor will use his Mac for this process which occurs very rarely. Let us forget this

Le 28 avr. 2020 à 21:41, holvi-mikael [email protected] a écrit :

 Sorry to say, not yet clear what should be done by the component.

It looks like you are using some Javascript library that has a popupGraphic method, and somewhere it is referring to popup.opener which usually means the opening window, not set in this case.

Nothing here that gives me an idea what to change.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

cvpe avatar Apr 28 '20 20:04 cvpe

This is interesting

cvpe avatar Apr 29 '20 06:04 cvpe

This works js_script = "window.open = function(open) { return function (url, name, features) { window.location.href = url; return window; }; } (window.open);" web.add_script(js_script)

cvpe avatar Apr 29 '20 06:04 cvpe

Thanks! Unfortunately, the issue that you highlighted is not only related to window.open, but also <a href> tags with target set to ”_blank”. The WKWebView user interaction delegate would handle both, but so far I have managed only a crash or at best a blank view opening.

mikaelho avatar May 04 '20 16:05 mikaelho

identified problem is half solved

cvpe avatar May 04 '20 16:05 cvpe