지금 내가하고있는 일은 URL에 몇 가지 매개 변수를 추가하고 해당 URL을 서버에 게시하여 해당 내용을 복구하는 것입니다. 이것은 지금까지 잘 작동합니다. URL :Iframe 요청에 매개 변수를 게시하는 방법
var uri = "test.html?isJSON=true";
AIM.download(uri,{'onStart' : function(){return true;}, 'onComplete' : function(response){
if(response==undefined || response=="")
return;
setMessage("generateMessage",response,"error");
}});
AIM = {
frame : function(c,u) {
var n = 'f' + Math.floor(Math.random() * 99999);
var token = "";
if(u==undefined || u=="")
u="about:blank";
if(JSLI.TOKEN_VALUE && JSLI.TOKEN_VALUE !=""){
if(u && u.indexOf('?') != -1) {
u = u + '&' +JSLI.TOKEN_NAME+"="+JSLI.TOKEN_VALUE;
} else {
u = u + '?' +JSLI.TOKEN_NAME+"="+JSLI.TOKEN_VALUE;
}
}
var d = document.createElement('DIV');
d.innerHTML = '<iframe style="display:none" src="'+ u +'" id="'+n+'" name="'+n+'" onload="AIM.loaded(\''+n+'\')"></iframe>';
document.body.appendChild(d);
var i = document.getElementById(n);
if (c && typeof(c.onComplete) == 'function') {
i.onComplete = c.onComplete;
}
return n;
},
form : function(f, name) {
f.setAttribute("action", attachToken(f.action));
f.setAttribute('target', name);
},
submit : function(f, c) {
AIM.form(f, AIM.frame(c));
if (c && typeof(c.onStart) == 'function') {
return c.onStart();
} else {
return true;
}
},
loaded : function(id) {
var i = document.getElementById(id);
if (i.contentDocument) {
var d = i.contentDocument;
} else if (i.contentWindow) {
var d = i.contentWindow.document;
} else {
var d = window.frames[id].document;
}
if (d.location.href == "about:blank"
&& i.src == "about:blank") {
return;
}
if(d.location.href.indexOf("login.html?expired=true")!=-1){
document.location.href = "login.html?expired=true";
return;
}
if (typeof(i.onComplete) == 'function') {
i.onComplete(d.body.innerHTML);
}
},
download:function(u,c)
{
AIM.frame(c,u);
if (c && typeof(c.onStart) == 'function') {
return c.onStart();
} else {
return true;
}
}
};
여기까지 코드가 잘 작동합니다. 이제 uri에 추가하여 보낼 수없는 텍스트 데이터도 보내려고합니다. 그래서 양식을 만들지만이 방법을 사용하여 양식 값을 보내는 방법을 해결할 수 없습니다.
<form id="frmKey" name="frmKey">
<input type="hidden" name="txt" id="txt"/>
</form>
[HTTP POST 요청으로 Iframe에 매개 변수를 보내는 방법] 가능한 복제본 (http://stackoverflow.com/questions/6730522/how-to-send-parameter-to-iframe-with-a) -http-post-request) – Mephiztopheles