Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Execute script which is on another server

I want to execute javascript file which is on another server and get the output of that script from my javascript code. Is there any way of doing this? Thanks in advance.

like image 625
Rohan Veer Avatar asked May 24 '26 04:05

Rohan Veer


1 Answers

The file which is on another server contains document.write method. Can I get that output in my javascript variable?

Only by overriding document.write and then loading the new script.

function capture(data) {
    // do something with data
}

document.write = capture;

var script = document.createElement("script");
script.src = "http://example.com/example.js";
document.body.appendChild(script);
like image 109
Quentin Avatar answered May 26 '26 17:05

Quentin