自动在第三方网站中填写详细信息

阿努·巴兰(Anuj Balan)

我有一个包含iframe(显示第三方网站)的页面。单击页面上的一个按钮后,我输入的用户名应从我的iframe中转到该第三方网站并进行设置。我已经尝试了一段时间,并阅读了有关“相同来源政策”的信息,因此一直在尝试使用“ CORS(跨源资源共享) ”。我不知道是否允许尝试任何操作,但这是我到目前为止所做的。

我不知道如何从这里开始。

<iframe name="ifr" id="ifr" height="200" width="200" src="https://somethirdPartyWebsite.com"/> </iframe><br/>
<input type="submit" id="submit" onclick="validate()" />
<script type="text/javascript">
function validate(){
    var request = createCORSRequest("get", "https://ala.kcpl.com/ala/mainLogin.cfm");
    alert("request-->"+request);
    if (request){
        request.onload = function() {
            alert("In onload...");
        };
        request.onreadystatechange = stateChanged();
        request.send();
    }
}

function createCORSRequest(method, url){
    var xhr = new XMLHttpRequest();
    if ("withCredentials" in xhr){
        xhr.open(method, url, true);
    } else if (typeof XDomainRequest != "undefined"){
        xhr = new XDomainRequest();
        xhr.open(method, url);
    } else {
        xhr = null;
    }
    return xhr;
}

function stateChanged(){
    alert("State Changed..");
}

**输出:**在IE中,正在接收警报(“ request->”),警报(“状态已更改”),警报(“正在加载”)。

在Firefox中,正在收到alert(“ request->”),alert(“ State Changed”)。

问题:我从中可以得出什么结论,以及如何继续在iframe ifr中提供的第三方网站的文本字段中设置值

我想我需要做些类似的事情

$("#ifr").contents().find('#inputUsername').val()="ValueToEnter".

不熟悉UI编码,请不要皱眉:)

不明确的

你不能 同源政策不允许这样做。

CORS应该在服务器端设置,而不是可以在客户端配置的东西。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章