//关于日期控制函数
//说明窗口
//6成显示新的窗口
function pop_my_window1(filename,id){
var winreswidth = screen.width*0.6;
var winresheight = screen.height*0.6;
var winbox = window.open(filename+id, "", "width="+winreswidth+",height="+winresheight+",top="+(screen.height-winresheight)/2+",left="+(screen.width-winreswidth)/2+",toolbar=no,menubar=no,location=no,status=no,scrollbars=1,resizable=1");
//var winbox = window.showModalDialog(filename+id, "", "dialogWidth="+winreswidth+"px;dialogHeight="+winresheight+"px;dialogTop="+(screen.height-winresheight)/2+"px;dialogLeft="+(screen.width-winreswidth)/2+"px;toolbar=no;menubar=no;location=no;status=no;scrollbars=1;resizable=1");
}
//对话显示窗口
function pop_my_window2(STR,filename,id){
pop=window.confirm (STR+"\n\n 是否继续?");
if(pop==true){
window.location.href = filename+id;
}
else{
return;
}}
//8成显示『showModalDialog』方法的窗体
function pop_my_window3(filename){
var winreswidth=screen.width*0.8;
var winresheight=screen.height*0.6;
var aboutbox = showModalDialog(filename, "", "dialogWidth:"+winreswidth+"px; dialogHeight:"+winresheight+"px; status:no; help:no");
}
//全屏显示新的窗口
function pop_my_window4(filename,id){
var winreswidth = screen.width*1;
var winresheight = screen.height*1;
var winbox = window.open(filename+id, "", "width="+winreswidth+",height="+winresheight+",top="+(screen.height-winresheight)/2+",left="+(screen.width-winreswidth)/2+",toolbar=no,menubar=no,location=no,status=no,scrollbars=1,resizable=1");
}
//全屏显示『showModalDialog』方法的窗体
function pop_my_window5(filename){
var winreswidth=screen.width*1;
var winresheight=screen.height*1;
var aboutbox = showModalDialog(filename, "", "dialogWidth:"+winreswidth+"px; dialogHeight:"+winresheight+"px; status:no; help:no");
}
//层操作中的控制函数
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i0 && parent.frames.length) {
d=parent.frames[n.substring(p+1)].document;
n=n.substring(0,p);
}
if(!(x=d[n])&&d.all) x=d.all[n];
for(i=0;!x && id.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
return x;
}
function copyCode(obj) {
var rng = document.body.createTextRange();
rng.moveToElementText(obj);
rng.scrollIntoView();
rng.select();
rng.execCommand("Copy");
rng.collapse(false);
}
function runCode(obj) {
var winname = window.open('', "_blank", '');
winname.document.open('text/html', 'replace');
winname.document.writeln(obj.value);
winname.document.close();
}
function saveCode(obj) {
var winname = window.open('', '_blank', 'top=10000');
winname.document.open('text/html', 'replace');
winname.document.writeln(obj.value);
winname.document.execCommand('saveas','','code.htm');
winname.close();
}
function cleanBR() {
var area = document.getElementsByTagName('TEXTAREA');
for (var i=0; i/ig, '');
area[i].value = area[i].value.replace(/(\xA0\x20){4}/ig, '\t');
area[i].value = area[i].value.replace(/\xA0\x20\xA0/ig, ' ');
area[i].value = area[i].value.replace(/\xA0\xA0/ig, ' ');
}
}
//设置 中英文 转换Cookie的 函数
function SetCookie (name, value)
{
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
document.cookie = name + "=" + escape (value) +
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) +
((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");
}
function getCookieVal (offset)
{
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie (name)
{
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return getCookieVal (j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}
//两个 select对象 互相选择 的 函数
function copyToList(from,to) //from表示:包含可选择项目的select对象名字 to表示:列出可选择项目的select对象名字 //你可以根据你的具体情况修改
{
fromList = eval('document.forms[0].' + from);
toList = eval('document.forms[0].' + to);
if (toList.options.length > 0 && toList.options[0].value == 'temp')
{
toList.options.length = 0;
}
var sel = false;
for (i=0;i"+document.all[i].childNodes[s].innerHTML+"
";
}
}
}
//不是按钮的input表单域应用
if(document.all[i].tagName.toLowerCase() == "input"){
if(!(document.all[i].type == "button" || document.all[i].type == "submit" || document.all[i].type == "reset")){
setDisableColor(document.all[i]);
}
}
//select表单域应用
else if(document.all[i].tagName.toLowerCase() == "select"){
setDisableColor(document.all[i]);
}
//textarea表单域应用
else if(document.all[i].tagName.toLowerCase() == "textarea"){
setDisableColor(document.all[i]);
}
}
}
//将页面中的readonly,disabled成立的表单域底色变暗
function setDisableColor(obj){
if(typeof(obj) == "object" ){
if (!obj.getAttribute("readonly") == null || obj.getAttribute("readonly") == true || obj.getAttribute("readonly") == "readonly") {
obj.setAttribute("className","gyrt_readonly");
}
if (!obj.getAttribute("disabled") == null || obj.getAttribute("disabled") == true || obj.getAttribute("disabled") == "disabled") {
obj.setAttribute("className","gyrt_disabled");
}
}
}
///
/// 给小流程按钮前面加一个用户定义的客户端按钮
///
/// 用于定位的小流程按钮ID
/// 新按钮的ID
/// 新按钮的表现名称
/// 新按钮的Onclick事件脚本
function AddNewButtonToPage(p_strOBtnName,p_strNBtnName,p_strNBtnValue,p_strNFunName) {
objBtn = document.getElementById(p_strOBtnName);
strHtmlBtn = "";
if(objBtn != null && objBtn != "undefined" ){
objBtn.outerHTML = "\r" + strHtmlBtn + "\r" + objBtn.outerHTML ;
}else{
return ;
}
}
//匿名登陆函数
//重置表单内容
function ClearLoginRedirectParameter(){
with (top.window.topFrame.window.LoginRedirect.document.forms[0]){
action = "";
hid_StaffNO.value = "";
hid_StaffName.value = "";
hid_DepID.value = "";
hid_DepName.value = "";
hid_ProjectCD.value = "";
DefaultUrl.value = "";
}
}
//打印表单信息
function AlertLoginRedirectParameter(){
with (top.window.topFrame.window.LoginRedirect.document.forms[0]){
alert("action:" + action);
alert("hid_StaffNO:" + hid_StaffNO.value);
alert("hid_StaffName:" + hid_StaffName.value);
alert("hid_DepID:" + hid_DepID.value);
alert("hid_DepName:" + hid_DepName.value);
alert("hid_ProjectCD:" + hid_ProjectCD.value);
alert("DefaultUrl:" + DefaultUrl.value);
}
}
//设置表单信息
function SetLoginRedirectParameter(p_SubSysCode,p_SubSysURL){
with (top.window.topFrame.window){
// ------- 如果用公共项目测试可以取消下面注释 ------------ //
// ------- LoginRedirect.document.forms[0].action = "/IMSWFUI/Default.aspx"; ------------- //
LoginRedirect.document.forms[0].action = p_SubSysURL;
LoginRedirect.document.forms[0].hid_StaffNO.value = document.forms[0].hid_StaffNO.value;
LoginRedirect.document.forms[0].hid_StaffName.value = document.forms[0].hid_StaffName.value;
LoginRedirect.document.forms[0].hid_DepID.value = document.forms[0].hid_DepID.value;
LoginRedirect.document.forms[0].hid_DepName.value = document.forms[0].hid_DepName.value;
LoginRedirect.document.forms[0].hid_ProjectCD.value = document.forms[0].hid_ProjectCD.value;
}
}
//提交表单信息
function ActionLoginRedirectParameter(p_SubSysCode,p_SubSysURL){
with (top.window.topFrame.window.LoginRedirect.document.forms[0]){
ClearLoginRedirectParameter();
SetLoginRedirectParameter('',p_SubSysURL);
//AlertLoginRedirectParameter();
btnSumbit.click();
}
}
//个人工作台的他系统任务跳转
function MyWorksDailyWrkRedirect(p_SubSysURL,p_dbURL){
//第一步:参数 p_dbURL 写入 LoginRedirect.htm 的DefaultUrl域
//第二步:用户信息写入LoginRedirect.htm 的对应域
//第三步:修改LoginRedirect.htm表单 的action到 参数p_SubsysURL
//第四步:提交LoginRedirect.htm表单
//top.window.location.href= p_SubSysURL + "?DefaultUrl=" + p_dbURL;
with (top.window.topFrame.window.LoginRedirect.document.forms[0]){
ClearLoginRedirectParameter();
SetLoginRedirectParameter('',p_SubSysURL);
DefaultUrl.value = p_dbURL;
//AlertLoginRedirectParameter();
btnSumbit.click();
}
}
///
/// 同步页面上的两个机组号 或者相同表单域
///
/// 文档对象路径
/// 第一个页面元素,必须是SELECT域
/// 第二个页面元素,必须是SELECT域
function SynchronousUNIT(p_DOMpath,p_objFirst,p_objSecond){
var objFirst = p_objFirst;
var objSecond = p_objSecond;
var objPath = "document.forms[0]";
if (p_DOMpath != "") {
objPath = p_DOMpath;
}
if (typeof(p_objFirst) != "object") {
objFirst = eval(objPath + "." + p_objFirst);
}
if (typeof(p_objSecond) != "object") {
objSecond = eval(objPath + "." + p_objSecond);
}
with(objPath){
if (objFirst.tagName.toLowerCase() == "select" && objSecond.tagName.toLowerCase() == "select") {
objSecond.selectedIndex = objFirst.selectedIndex;
}
else{
alert("该函数仅支持两个select域同步");
}
}
}
//页面级别的事件处理
//页面上的单击事件
function DocOnclick()
{
clickHandler();
}
//页面上的脚本异常
function WinOnerror()
{
killErrors();
}
//窗体的加载事件
function WinOnload()
{
ChangeTdHtml();
cleanBR();
//window.status = "Hello";
}
document.onclick = DocOnclick;
window.onerror = WinOnerror;
window.onload = WinOnload;
//焦点自动切换,如果输入一个参数,该参数表示当前控件,焦点自动切换到按TabIndex排序的下一个控件
//如果输入两个参数,第二个参数表示新焦点所在控件Id
function focusChange()
{
if(arguments.length == 1)
{
curControl = arguments[0];
var curTabIndex = curControl.tabIndex;
var nextTabIndex, nextControl;
var nextInit = false;
var curForm = curControl.parentElement;
if(curControl.value.length >= curControl.getAttribute("maxlength"))
{
var tempControl, tempTabIndex;
for(var i=0; i curTabIndex)
{
if(nextInit)
{
if(tempTabIndex < nextTabIndex)
{
nextControl = tempControl;
nextTabIndex = tempTabIndex;
}
}
else
{
nextControl = tempControl;
nextTabIndex = tempTabIndex;
nextInit = true;
}
}
}
if(nextInit)
{
nextControl.focus();
}
}
}
if(arguments.length == 2)
{
curControl = arguments[0];
nextId = arguments[1];
if(curControl.value.length >= curControl.getAttribute('maxlength'))
{
nextId = arguments[1];
document.getElementById(nextId).focus();
}
}
}
//将文本框的回车键模拟成Tab键,如果输入一个参数,该参数表示新焦点所在控件Id
function enterToTab()
{
if(event.keyCode == 13)
{
event.keyCode = 9;
if(arguments.length == 1)
{
var nextId = arguments[0];
setTimeout("document.getElementById('"+nextId+"').focus();", 100);
event.returnValue = false;
}
}
}
function GRFW_TextBox_KeyDown_Init(){
for( var i = 0; i < GRFW_Select_TextBoxs.length; i++ )
{
var txt = GRFW_TextBox_FindControl(GRFW_Select_TextBoxs[i]);
var img = GRFW_TextBox_FindControl(GRFW_Select_Images[i]);
if ( txt != null && img != null) {
GRFW_TextBox_KeyDown_Load( txt,img );
}
}
}
function GRFW_TextBox_KeyDown_Load(txt,img)
{
txt.onkeypress = new Function(GetEventString(img.onclick));
}
function GRFW_TextBox_FindControl(controlName)
{
for ( var i = 0; i < document.forms.length; i++ ) {
var theForm = document.forms[i];
var theControl = theForm[controlName];
if ( theControl != null ) {
return theControl;
}
}
return null;
}
function GetEventString(ev)
{
var script = "var e=window.event;if(e.keyCode != 32){event.returnValue = false; return '';}";
if (typeof(ev)=="function") {
ev = ev.toString();
ev = ev.substring(ev.indexOf("{") + 1, ev.lastIndexOf("}")-1);
}
else
{
ev="";
}
return script + ev + "event.returnValue = false;return '';";
}
function GRFW_CopyTo_TextBox_KeyDown_Init(){
for( var i = 0; i < GRFW_Select_TextBoxs.length; i++ )
{
var txt = GRFW_TextBox_FindControl(GRFW_Select_TextBoxs_CopyTo[i]);
var img = GRFW_TextBox_FindControl(GRFW_Select_Images_CopyTo[i]);
if ( txt != null && img != null) {
GRFW_TextBox_KeyDown_Load( txt,img );
}
}
}
//函数名:chkdate
//功能介绍:检查是否为日期
//参数说明:要检查的字符串like:2008-12-18
//返回值:0:不是日期 1:是日期
function chkdate(datestr)
{
var lthdatestr;
if(datestr!="")
lthdatestr=datestr.length;
else
lthdatestr=0;
var tmpy="";
var tmpm="";
var tmpd="";
//var datestr;
var status;
status=0;
if(lthdatestr==0)
return 0
for(i=0;i2)
{
//alert("Invalid format of date!");
return 0;
}
if((status==0)&&(datestr.charAt(i)!='-'))
{
tmpy=tmpy+datestr.charAt(i)
}
if((status==1)&&(datestr.charAt(i)!='-'))
{
tmpm=tmpm+datestr.charAt(i)
}
if((status==2)&&(datestr.charAt(i)!='-'))
{
tmpd=tmpd+datestr.charAt(i)
}
}
year=new String(tmpy);
month=new String(tmpm);
day=new String(tmpd)
//tempdate= new String (year+month+day);
//alert(tempdate);
if((tmpy.length!=4)||(tmpm.length>2)||(tmpd.length>2))
{
//alert("Invalid format of date!");
return 0;
}
if(!((1<=month)&&(12>=month)&&(31>=day)&&(1<=day)))
{
//alert ("Invalid month or day!");
return 0;
}
if(!((year%4)==0)&&(month==2)&&(day==29))
{
//alert ("This is not a leap year!");
return 0;
}
if((month<=7)&&((month%2)==0)&&(day>=31))
{
//alert ("This month is a small month!");
return 0;
}
if((month>=8)&&((month%2)==1)&&(day>=31))
{
//alert ("This month is a small month!");
return 0;
}
if((month==2)&&(day==30))
{
//alert("The Febryary never has this day!");
return 0;
}
return 1;
}