Google reCAPTCHA in Confirm Message Box Problem

I am attempting to utilize the Google reCAPTCHA in a CONFIRM message box. It works perfectly when the confirm box is run ‘onload’ but when launched using a function, it fails to load.

Here is a snippet showing what is happening (click ‘CANCEL’ for the onload version - the one that works - and then click ‘SHOW CONFIRM’ to show the one that does not work). NOTE: same code in both cases except for function.

https://snippet.dhtmlx.com/maysp0u7

Hello Neil.

In such async solutions you should try to use the grecaptcha.render() method.

Like:
https://snippet.dhtmlx.com/67vx6oad

1 Like

Awesome! Thank you for this input/suggestion.

Even though the CAPTCHA now shows in the dhxWindow, I am now getting a ‘cross-origin’ error (Uncaught DOMException: Blocked a frame with origin “https://www.google.com” from accessing a cross-origin frame at window_blur). As I read about this error, it appears that the way the dhxWindow is being rendered conflicts with this security protocol which restricts how a document or script loaded by one origin can interact with a resource from another origin. What is the work-around for this (without compromising the security)? Thank you.

The problem seems to be not with the dhxWindow itself.
Please, refer to the following topic:

it may help.

Hello. And, thank you. I had reviewed this same Stack Overflow page prior to my previous question. The accepted answer (and popular with 1110 upvotes) deals with an i-frame with an origin from a DIFFERENT PAGE which is not relevant here given the dhxWindow opens on the SAME page. While window.open() is suggested for an i-frame on the SAME page, the reference page specifically states this method is not recommended due to pop-up blockers etc.

If the dhxWindow is opened on the same page and I have no control over the ID issued (const frame = document.getElementById(‘your-frame-id’)) for the i-frame (see screenshot), I am not seeing how to overcome this cross-origin error. I would appreciate any suggestions/input. Thank you.

image

Could you please, provide a complete demo or a demo link, where the problem can be reconstructed locally?

How would I do that without revealing our Site Key?

Hello. After much investigation, this problem turns out to be a Google Extension conflict and nothing to do with DHX. Sorry for wasting your time.

1 Like

It’s ok. Hope the problem was successfully solved.
Best regards.