自动填写第三方网站的详细信息
Filling the details in a third party website automatically
我有一个带有 iframe(显示第三方网站)的页面。单击我页面中的一个按钮,我输入的用户名应该从我的 iframe 转到第三方网站并进行设置。我已经尝试了一段时间并阅读了有关 'Same Origin Policy' 的信息,因此一直在尝试使用 '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-->")、警报("State Changed")、警报("In load")。
在 Firefox 中,收到警报("request-->")、警报("State Changed")。
问题:我要从中得出什么结论,我该如何继续并在 iframe 中存在的第三方网站的文本字段中设置值ifr
我想我需要做一些类似的事情
$("#ifr").contents().find('#inputUsername').val()="ValueToEnter".
不熟悉UI编码,请不要皱眉:)
你不能。同源政策不允许这样做。
CORS 应该在服务器端设置,它不是您可以在客户端配置的东西。
我有一个带有 iframe(显示第三方网站)的页面。单击我页面中的一个按钮,我输入的用户名应该从我的 iframe 转到第三方网站并进行设置。我已经尝试了一段时间并阅读了有关 'Same Origin Policy' 的信息,因此一直在尝试使用 '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-->")、警报("State Changed")、警报("In load")。
在 Firefox 中,收到警报("request-->")、警报("State Changed")。
问题:我要从中得出什么结论,我该如何继续并在 iframe 中存在的第三方网站的文本字段中设置值ifr
我想我需要做一些类似的事情
$("#ifr").contents().find('#inputUsername').val()="ValueToEnter".
不熟悉UI编码,请不要皱眉:)
你不能。同源政策不允许这样做。
CORS 应该在服务器端设置,它不是您可以在客户端配置的东西。