📄 document.js
字号:
var all="all";
/**
* 获得对象所在的表单对象
*/
function getForm(formName){
if(formName==null){
var objEvent = window.event.srcElement;
var objParent = objEvent.parentElement;
while (objParent!=null){
if(objParent.tagName=="FORM"){
break;
}
objParent=objParent.parentElement;
}
if(objParent!=null&&objParent.tagName=="FORM"){
return objParent;
}
else{
var e = new Error("没有找到表单对象");
throw e;
}
}
else{
var objForm= document.forms[formName];
if(objForm!=null){
return objForm;
}
else{
var e = new Error("没有找到表单对象");
throw e;
}
}
}
/**
* 获得表单中的对象
* 调用getForm()
*/
function getFormElement(name){
var oForm=getForm();
return oForm.elements(name);
}
/**
* 获得单元格对象
* oRows行对象
* id单元格的id名字
* 姜敏
*/
function getCell(oRows, id){
var oCells=oRows.cells;
var oCell=null;
for(var i=0;i<oCells.length;i++){
oCell = oCells[i];
if(oCell.id==id){
break;
}
}
return oCell;
}
/**
* 获得对象数组
* name:对象数组的名字
* oWindow:window对象
* 姜敏
*/
function getObjects(name, oWindow){
var objs
if(oWindow==null){
objs = window.document.getElementsByName(name);
}
else{
objs = oWindow.document.getElementsByName(name);
}
return objs;
}
/**
* 获得对象
* id:对象的id
* oWindow:window对象
* 姜敏
*/
function getObject(id, oWindow){
var obj;
if(oWindow==null){
obj = window.document.getElementById(id);
}
else{
obj = oWindow.document.getElementById(id);
}
return obj;
}
/**
* 触发动作的对象必须是inupt,button等
* 提交按钮所在的表单
* url:表单要提交的动作(可选)
* 姜敏
*/
function postForm(formName, url){
var oForm = getForm(formName);
// if(window.dialogArguments==null){
oForm.target ='_self';
// }
if(url!=null){
oForm.action = url;
}
oForm.submit();
}
/**
* 触发动作的对象必须是inupt,button等
* 提交按钮所在的表单到空白窗口
* url:表单要提交的动作(可选)
* 姜敏
*/
/*function postFormBlank(url){
var obj = window.event.srcElement;
var oForm = obj.form;
oForm.target ='_blank';
if(url!=null){
oForm.action = url;
}
oForm.submit();
}*/
/**
* 触发动作的对象必须是inupt,button等
* 提交按钮所在的表单到新开无工具栏窗口,用于打印窗口
* formName:要提交的表单名(可选)
* 姜敏
*/
function postFormPrint(formName, url){
var oForm = getForm(formName);
var sFeatures = "toolbar=no, menubar=no, scrollbars=no,resizable=yes, "
+ "location=no, status=no,titlebar=no";
var name='notoolbar'+randomNum();
window.open('about:blank',name,sFeatures);
oForm.target = name;
if(url!=null) {
oForm.action = url;
}
oForm.submit();
}
function postFormBlank(formName, url){
var oForm = getForm(formName);
var sFeatures = "toolbar=no, menubar=no, scrollbars=no,resizable=yes, "
+ "location=no, status=no,titlebar=no,width=560, height=350,top=200,left=250";
var name='notoolbar'+randomNum();
window.open('about:blank',name,sFeatures);
oForm.target = name;
if(url!=null) {
oForm.action = url;
}
oForm.submit();
}
/**
* 触发动作的对象必须是inupt,button等
* 按回车提交表单
* formName:要提交的表单名称(可选)
* 姜敏
*/
function enterPostForm(url){
var ieKey = window.event.keyCode;
var obj = window.event.srcElement;
var oForm = obj.form;
if(ieKey==13) {
oForm.target ='_self';
if(url!=null){
oForm.action = url;
}
oForm.submit();
}
}
/**
* 触发动作的对象必须是inupt,button等
* 清除表单上的非隐藏域输入框的值
* 姜敏
*/
function clearForm(formName, param){
var objForm = getForm(formName);
for(var i=0; i < objForm.elements.length;i++){
var object=objForm.elements[i]
if(object.tagName=="INPUT"){
if(object.type=="file" || object.type=="password" || object.type=="text"){
object.value="";
}
/*if(object.type=="checkbox" || object.type=="radio"){
object.checked=false;
}*/
if(object.type=="hidden"){
if(param=='all'){
object.value="";
}
}
}
if(object.tagName=="SELECT"){
//object.value="";
object.options[0].selected=true;
}
if(object.tagName=="TEXTAREA"){
object.value="";
}
}
}
/**
* 显示和隐藏对象
* IDName:对象ID
* status:根据状态来显示和隐藏(可选)
* 姜敏
*/
function openOrCloseID(IDName, status){
try{
var obj=getObject(IDName);
if(status!=null){
obj.style.display=(status==true)?"block":"none";
}
else{
obj.style.display=(obj.style.display == "none")?"block": "none";
}
}
catch(e){
}
}
/**
* 复选框的状态选择(全/不选,)
*/
function statusChecked(IDName, status){
var objCheckBoxs = getObjects(IDName);
if(objCheckBoxs!=null){
for(var i=0;i<objCheckBoxs.length;i++){
objCheckBoxs[i].checked=(status!=null)?status:(!objCheckBoxs[i].checked);
}
}
}
/**
* 分页取码窗口的复选框状态选中函数(多行取码)
* parentHiddenName:父窗口中的主键ID的隐藏域名(数组)
* selfCheckBoxName:当前窗口中的复选框名(数组)
*/
function statusCheckedById(parentHiddenName, selfCheckBoxName){
var objHiddens=window.parent.document.getElementsByName(parentHiddenName);
var objCheckBoxs=window.document.getElementsByName(selfCheckBoxName);
if(objHiddens==null) return;
if(objCheckBoxs==null) return;
var checkBoxValue;
var hiddenValue;
for(var i=0;i<objCheckBoxs.length;i++){
checkBoxValue=objCheckBoxs[i].value;
for(var j=0;j<objHiddens.length;j++){
hiddenValue=objHiddens[j].value;
if(checkBoxValue==hiddenValue){
objCheckBoxs[i].checked=true;
break;
}
}
}
}
/**
* 分页取码窗口的复选框状态选中函数(单个输入框中名称以逗号分割)
* parentInputName:父窗口中的输入框名称
* selfCheckBoxName:当前窗口中的复选框名(数组)
*/
function statusCheckedByName(parentInputName, selfCheckBoxName){
var objInput = window.parent.document.getElementById(parentInputName);
var objCheckBoxs = window.document.getElementsByName(selfCheckBoxName);
if(objInput==null) return;
if(objCheckBoxs==null) return;
var inputValue = objInput.value;
var checkBoxValue;
for(var i=0;i<objCheckBoxs.length;i++){
checkBoxValue=objCheckBoxs[i].value;
if(inputValue.indexOf(checkBoxValue)!=-1){
objCheckBoxs[i].checked=true;
}
}
}
/*
* 显示Table中的每个单元格中的innerHTML, 用于取码测试
* tableID:要显示的tableID
* textID:用于存放innerHTML的备注框
* 姜敏
*/
function showHtml(tableID, textID){
var oTable = document.getElementById(tableID);
var rowlength=oTable.rows.length;
var msg="";
for(i=1;i<rowlength;i++){
var row = oTable.rows[i];
var cells = row.cells;
for(j=0;j<cells.length;j++){
var cell = cells[j];
msg += cell.innerHTML+"\n";
}
}
document.getElementById(textID).value=msg;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -