Search code examples
javascriptiframepaypalcross-domain

SecurityError: Blocked a frame with origin from accessing a cross-origin frame with Paypal button


Is there way to click programatically on PayPal sdk button which is hidden in iframe? Iframe it is not ours, it comes from payPal.

Right now it brings the error:

Uncaught DOMException: Blocked a frame with origin "http://localhost:4000" from accessing a cross-origin frame.

I have tried to do

const button = document.querySelector(#${CONTAINER_ID})?.querySelector('iframe') .contentWindow.document.querySelector('.paypal-button').click();


Solution

  • No, no browser JavaScript permits cross-origin operations on a domain you do not control.