How to carry out Cross Domain request in a Webbrowser Control?

前端 未结 5 2332
太阳男子
太阳男子 2021-02-10 03:43

As you know doing Cross Domain XMLHTTP requests is not allowed for security reasons under Internet Explorer.

I have a WebBrowser Control and I\'m using DocumentTex

5条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-10 04:16

    I don't understand on which domain you don't have access to the Javascript... Have you tried using the script tag to get the data that you want from a different domain? You can use the JSONP idiom to namespace the data...

    var head = document.getElementsByTagName("head")[0];
    var script = document.createElement("script");
    script.src = "anotherdomain.com/data?callback=myFunction";
    head.appendChild(script);
    

    And then on "/data":

    myFunction({
        // data here
    });
    

提交回复
热议问题