概述:父页面A调用子页面B,从子页面B返回数据从而在父页面A上构建一行追加到原有的表格上;
----------------------------------------------------------------------------------------
A页面的调用脚本:


1

2

3

4



5

6

7

8



9

10

11

12

13

14

15



16

17

18

19

20

21



22

23

24



25

26

27

28

29



30

31

32

33

34

35

36



37

38

39

40



41

42

43

44

45

46

47

48

A页面相关元素:


1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

-------------------------------------------------------------
B页面的js脚本:
Code
B页面的HTML元素:
.....
一个和A页面上一摸一样的表格,只不过是GridView动态生成的;一个按钮关联SelectSave()函数。
------------------------------------------------------------------------------------------------
总结:
- 熟悉了下js实现类的方法,可惜的是不能在页面间传递js对象 ,指的是子页面关闭回到父页面这种情况,如果是是通过iframe嵌套的话另当别论,因为js对象是引用类型而页面关闭的时候js就会消失(不够严谨);
- 体会到了W3C标准的重要性,IE、FireFox等没有统一的页面对象操作方法,导致我一天搜索了不下40个页面,浪费了相当长的时间和体力才搞定;
- 并且在IE下不能调试脚本,只好alert()这里,alert()那里;FireFox下的调试用的插件都摆在一边没法子用;
- appendChild(); document.createElement(""); Row1.setAttribute("align","center"); 这几个函数在IE下都不能用;最终用 insertRow();insertCell;Row1.align="center";才搞定。
- 给元素添加事件相应函数的问题用 "莫名函数"....

function Info(id,code,name,specs,btime,man,value) //写的一个js类,:-)权作练习用,多此一举啦
{
this.AccountID=id;
this.AccountCode=code;
this.ResName=name;
this.Specs=specs;
this.PurchaseDay=btime;
this.Principal=man;
this.ResidualCost=value;
if(typeof Info._initialized=="undefined")
{
Info.prototype.ToStr=function()
{
return this.AccountID+','+this.AccountCode+','+this.ResName+','+this.Specs+','+this.PurchaseDay+','+this.Principal+','+this.ResidualCost;
};
Info._initialized=true;
}
}
var info;
function ClickRow(row)//绑定在GridView行上的属性,row-是GridViewRow (-_- "有点啰嗦啦)
{
info=new Info(row.id,row.children[1].innerHTML,row.children[0].innerHTML,row.children[2].innerHTML,row.children[3].children[0].innerHTML,row.children[4].innerHTML,row.children[5].innerHTML);
//alert(info.ToStr());
document.getElementById('HdnRow').value=row.innerHTML;
document.getElementById('btnAdd').disabled=false;
}
function SelectSave()//最后用来回传值的按钮
{
//alert(info.ToStr());
var reValue=document.getElementById('HdnRow').value;
window.parent.window.returnValue=info.ToStr();
window.close();
}