Index.jsp 分析
完整的JS部分:(出去外部引用的js)应该是还没有完成
<script type="text/javascript" language="javascript"> var isMouseIn = false; var winType = 0;//0:close,1:refresh var parentDlg = null; var cWin = null; var qqTime = null; </script>
首先定义一些后面会使用到的变量
<script type="text/javascript" language="javascript"> function iniPage() { iniBottom(); parentDlg = new BSDialogMG("parentDlg", "topMenu.open(false);"); parentDlg.imagePath = getDomain() + "/common/images/toolbar/"; parentDlg.show(); $("frm_tq").src = "http://m.weather.com.cn/m/pn12/weather.htm"; removeWait(); } function doQjItem(itemId) { var thisItem = this.getBarById(itemId); } function dotest() { openParentDlg("WDLOOKUP_DIG", "测试接口", 300, 180, fromObj, "WDLOOKUP", "DoRoleLookUpIni", "", window, true, false, "returnChangeKeyWin"); } function resetUserRet() { } </script>
1. iniPage 方法,初始化界面
function iniPage() { iniBottom(); ① parentDlg = new BSDialogMG("parentDlg", "topMenu.open(false);"); ② parentDlg.imagePath = getDomain() + "/common/images/toolbar/"; ③ parentDlg.show(); $("frm_tq").src = "http://m.weather.com.cn/m/pn12/weather.htm"; ④ removeWait(); ⑤ }
①iniBottom /common/script/index.js
function iniBottom() { var b = $("indexbody_bottom"); b.style.top = document.body.clientHeight - 29; b.style.display = "block"; }
设置首页的底部是29px高,这个显示效果要根据用户浏览器来决定,所以放在初始化页面这里
这个29px高的位置元素是一个类似windows操作系统的任务栏样式
②BSDialogMG /bsweb/js/bsdialog.js
第一个参数是Dialog的名字,第二个参数是mouseDownFun(鼠标点击后触发的函数)
parentDlg 很重要的,后面很多的窗体都是从它而创建的
if (this.mouseDownFun != null && this.mouseDownFun != "") {
eval(this.mouseDownFun);
}
JS:eval() 函数可计算某个字符串,并执行其中的的 JavaScript 代码。
该方法只接受原始字符串作为参数,如果 string 参数不是原始字符串,那么该方法将不作任何改变地返回。因此请不要为 eval() 函数传递 String 对象来作为参数。
如果试图覆盖 eval 属性或把 eval() 方法赋予另一个属性,并通过该属性调用它,则 ECMAScript 实现允许抛出一个 EvalError 异常。
参考网址:http://www.w3school.com.cn/js/jsref_eval.asp
③关于getDomain()
String getDomain() 返回cookie中Cookie适用的域名. 使用getDomain() 方法可以指示浏览器把Cookie返回给同 一域内的其他服务器,而通常Cookie只返回给与发送它的服务器。注意域名必须以点开始(例如.yesky.com)
④该链接的目标刚好是一个显示天气信息的网址
http://m.weather.com.cn/m/pn12/weather.htm
⑤removeWait /common/script/index.js
function removeWait() { $("my_bsimg_wait").removeNode(); $("my_bsimg_wait_div").removeNode(); }
这个方法就是用来清除那些页面加载前的页面元素,它和上面的一个方法有关:
function createWait() { var html = "<div id=\"my_bsimg_wait_div\" style=\"background-color:#b4d9f1;position: absolute;top:0;left:0;z-index:3000;100%; height:100%;\"></div>"; html += "<table id=\"my_bsimg_wait\" class=\"indexbody_wait\" align=\"center\"><tr><td align=\"center\"><img src=\""+ getDomain()+ "/common/images/wait.png\" align=\"center\"/></td></tr><tr><td height=\"55px;\" align=\"center\" valign=\"bottom\">系统加载中!精彩稍后呈现...</td></tr></table>"; document.writeln(html); }
这里利用JS方法创建了页面中的div和table。内容是首页加载完成之前页面显示的内容
2.重要的JS方法 doFunction
function doFunction(id, name, bsid, bsfun, paras, width, height, isMT, isResize, img, index) { var fromObj = {}; openParentDlg(id, name, width, height, fromObj, bsid, bsfun, paras, window,isMT, isResize, "returnChangeKeyWin", img, index); }
id和name是窗体的编号和标题,bsfun是JS函数,paras还不知道,isMT是判断是否是模式窗口(窗口的大小是不可以改变的),isResize是否可以改变大小,img是指小图片的位置(路径,其实只要给个名字就可以了),index不知道
3. openParentDlg
function openParentDlg(id, title, width, height, inObj, bsID, fun, paras, cWinName, isMT, isResize, retFun, img, index) { if (isMT) { isResize = false; } else { if (isResize != null && !isResize) { isResize = false; } else { isResize = true; } } // parentDlg.show(); var exStr1 = ":" + $F("pub_tusername"); var exStr2 = ":" + $F("pub_torgname"); var exStr3 = ""; var newDlg = parentDlg.openDlg(parentDlg.name + "_" + id, title, 0, 0,width, height, isMT, isResize, retFun, img, index, exStr1, exStr2, exStr3, true); if (newDlg != null) { newDlg.inObj = inObj; newDlg.win = cWinName; newDlg.startFun(); if (retFun != null && retFun != "") { newDlg.retFun = retFun; } newDlg.returnObj = null; frmBusiness.target = newDlg.target; doCommit(bsID, fun, paras); } }
红色背景的内容在后文中将提到
从这里可以知道模式窗口的大小是不可以改变的,非模式窗口可以设置。下面的其他内容不知道
其中的pub_tusername 和 pub_torgname 是页面中的元素,而且是隐藏的文本框,意思是该用户的用户名和他的机构名称
<form method="post" name="frmBusiness" action=""> <BS:text type="hidden" name="pub_tusername" /> <BS:text type="hidden" name="pub_torgname" />