欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

改变iframe里页面的内容

程序员文章站 2022-03-03 09:06:59
...

改变iframe里页面的内容

url="https://psh-ap-02.psh.corp.pegatron/gasite/WebSource/PI/UserOverTimeQuery.aspx?parameter=";
list_p =['__VIEWSTATE','__EVENTVALIDATION','UserOverTimeQuery:monthid01_ddl','UserOverTimeQuery:Kinds01_DDL','UserOverTimeQuery:imagebutton01','UserOverTimeQuery:imagebutton01','UserOverTimeQuery:monthid02_ddl'];
list_p2=['__EVENTTARGET','__EVENTARGUMENT'];
list_p3=['UserOverTimeQuery$OT_GV','Page$2'];
form1 = $('#Form1',window.top.frames['rightIframe'].document)[0];
dic ={};
console.log(form1,'form');
for(var i in list_p){
    if (i>5 || i<4){
	dic[list_p[i]]=form1[list_p[i]].value;
    console.log(form1[list_p[i]].value,i);
    }
}
	dic[list_p[4]+'.x']=29;
	dic[list_p[5]+'.y']=11;
  $.post(url,dic,function(result){
    //console.log(result,'result');
	window.top.frames['rightIframe'].document.children[0].outerHTML=result;
  });

另一種思路:
在總頁面直接操作子頁面,獲取數據而不受到影響。
方便操作:

form1 = $('#Form1',window.top.frames['rightIframe'].document)[0];
$('a[href*="Page"]',form1)
$($('a[href*="Page"]',form1)[0]).click();
沒有反應失敗了。

url="https://psh-ap-02.psh.corp.pegatron/gasite/WebSource/PI/UserOverTimeQuery.aspx?parameter=";
list_p =['__VIEWSTATE','__EVENTVALIDATION','UserOverTimeQuery:monthid01_ddl','UserOverTimeQuery:Kinds01_DDL','UserOverTimeQuery:imagebutton01','UserOverTimeQuery:imagebutton01','UserOverTimeQuery:monthid02_ddl'];
list_p2=['__EVENTTARGET','__EVENTARGUMENT'];
list_p3=['UserOverTimeQuery$OT_GV','Page$2'];
form1 = $('#Form1',window.top.frames['rightIframe'].document)[0];
dic ={};
console.log(form1,'form');
for(var i in list_p){
    if (i>5 || i<4){
	dic[list_p[i]]=form1[list_p[i]].value;
    console.log(form1[list_p[i]].value,i);
    }
}
	dic[list_p2[0]]=list_p3[0];
	dic[list_p2[1]]=list_p3[1];
  $.post(url,dic,function(result){
    console.log(result,'result');
  });

form1 = $('#Form1',window.top.frames['rightIframe'].document)[0];
form1.submit()
form1 = $('#UserOverTimeQuery_imagebutton01',window.top.frames['rightIframe'].document)[0];
form1.click()
count = $('#UserOverTimeQuery_OT_GV tr:first tr td',window.top.frames['rightIframe'].document).length;