有用的JS方法2

--如果页面报XML的错误,但是后台不报错的话,有可能是没有加载次方的原因
parseCondition();

--JS判断附件大小
/** 检查上传文件大小 */
function checkFileSize() {
var num = document.getElementsByName("browse").length;
for(var i = 0; i < num; i++) {
var fileName = document.getElementsByName("browse")[i].value;
if(fileName == "") continue;
var fileSystem = new ActiveXObject("Scripting.FileSystemObject");         
var file = fileSystem.GetFile (fileName);      
var fileSize = file.Size;
if(fileSize/1024/1024 > '${applicationScope.fileMaxSize}') {
return false;
}
}
return true;
}

--向TR或者TD里面添加字符串
function showResponseForLoadComments(originalRequest){
var flag = originalRequest.responseText;
var result = flag.split("^");
if(result.length >= 2){
var comments = result[0];
var availableTransitions = result[1];
//将上一次的批复记录隐藏
$("commentTable").style.display = 'none';
//将这次的批复记录显示出来
$("commentTd").style.display = 'block';
$("commentTd").innerHTML = comments;
}

}

--清除下拉框的option
function clearOption(transition){
if((null != transition) && (null != transition.options)){
for(var i=0; i<transition.options.length; i++) {
transition.removeChild(transition.options[i]);
}
}
}

--向下拉框添加option
function addOption(transition ,availableTransitions){
var availableTransitions = availableTransitions.split('|');
for(var i=0; i<availableTransitions.length; i++){
if((null == availableTransitions[i]) || ('' == availableTransitions[i]))continue;
transition.add(new Option(availableTransitions[i],availableTransitions[i]));
}
}

--JS换行
comments = comments.replace(/\!/g ,'!\n\r');
--HTML换行
comments = comments.replace(/\#/g ,'<br/>');

--子页面调用父页面的ID
var batchUse = window.dialogArguments.document.getElementById("batchUse");
--子页面调用父页面的JS方法
window.dialogArguments.changeBatchUse(batchUse);
--子页面调用父页面的变量
var parentGrid = window.dialogArguments.mygrid;

你可能感兴趣的:(js)