Using javascript from one site to do an alert on another site?

Site 1 contains the required code

Site 2 is modified using the Site code 1

Both sites are in php.

Are there any ways? Is it possible iframe?

2 answers 2

Browser security policy allows JS code to work only with data / DOM from the same domain - see Domain Restriction Rules . If you certainly want to change the elements in the frame from Site2 from the frame loaded from Site1 - see CORS .

Another option is to use window.postMessage() for communication between two sandboxes of different domains: listen to messages on Site 2, send data from Site 1 — data, not code.

    No you can not. But it is possible through curl to send a request to another server, and on it, in turn, to process this request and issue the corresponding response. You also need jQuery for this.