//字符串去重复
function StrDistinct(swd) {
Array.prototype.unique = function() {
var a = {}; for (var i = 0; i < this.length; i++) {
if (typeof a[this[i]] == "undefined")
a[this[i]] = 1;
}
this.length = 0;
for (var i in a)
this[this.length] = i;
return this;
}
var swdArray = swd.split(",")
var hahaArray = swdArray.unique();
var newStr = hahaArray.join(",");
return newStr;
}
//在屏幕中央弹出新窗口
function openNewWindow(width,height,url){
var startW = (screen.availWidth - width)/2;
var startH = (screen.availHeight - height)/2;
window.open(url,"_blank","left="+startW+",top="+startH+",height="+height+",width="+width+",status=no,resizable=1,scrollbars=yes,toolbar=no,menubar=no,location=no");
}
//在屏幕中央弹出打开Word的新窗口 added by zengbo 2007-10-24
function openWordWindow(url){
var width=800;
var height=600;
var startW = (screen.availWidth - width)/2;
var startH = (screen.availHeight - height)/2;
window.open(url,"_blank","left="+startW+",top="+startH+",height="+height+",width="+width+",status=no,resizable=1,scrollbars=yes,toolbar=no,menubar=yes,location=no");
}
//在屏幕中央弹出新窗口
function openNewWindowByMenu(width,height,url){
var startW = (screen.availWidth - width)/2;
var startH = (screen.availHeight - height)/2;
window.open(url,"_blank","left="+startW+",top="+startH+",height="+height+",width="+width+",status=yes,resizable=1,scrollbars=yes,toolbar=yes,menubar=yes,location=no");
}
//弹出全屏窗口
function openNewWindowByMenu(url){
window.open(url,"_blank","left=0,top=0,height="+screen.availHeight+",width="+screen.availWidth+",status=yes,resizable=1,scrollbars=yes,toolbar=yes,menubar=yes,location=no");
}
//在屏幕中央弹出模态窗口
function openModelWindow(width,height,url){
// var d = new Date;
// if(url.lastIndexOf("?")==-1){
// url = url+"?currTime="+d.getTime();
// }else{
// url = url+"&currTime="+d.getTime();
// }
window.showModalDialog(url, window, "dialogHeight:" + height + "px;dialogWidth:" + width + "px;center:Yes;Help:No;Resizable:No;Scroll:yes;Status:no;");
}
//在屏幕中央弹出公共的查询模态窗口
function openCommonQueryModelWindow(url){
openModelWindow(520,320,url);
}
//全选
function GVSelectAll(){
var len=document.forms[0].elements.length;
var i;
for (i=0;i<len;i++){
if (document.forms[0].elements[i].type=="checkbox" && document.forms[0].elements[i].name.indexOf("GridViewID")>-1){
document.forms[0].elements[i].checked=true;
}
}
}
//全选
function GVSelectAll(check){
var len=document.forms[0].elements.length;
var i;
for (i=0;i<len;i++){
if (document.forms[0].elements[i].type=="checkbox" && document.forms[0].elements[i].name.indexOf("GridViewID")>-1){
document.forms[0].elements[i].checked=check;
}
}
}
//全选
function GVSelectAll1(check) {
var len = document.forms[0].elements.length;
var i;
for (i = 0; i < len; i++) {
if (document.forms[0].elements[i].type == "checkbox" && document.forms[0].elements[i].name.indexOf("gvcheck") > -1) {
document.forms[0].elements[i].checked = check;
}
}
}
//反选
function GVSelectRever(){
var len=document.forms[0].elements.length;
var i;
for (i=0;i<len;i++){
if (document.forms[0].elements[i].type=="checkbox" && document.forms[0].elements[i].name.indexOf("GridViewID")>-1){
if(document.forms[0].elements[i].checked){
document.forms[0].elements[i].checked = false;
}else{
document.forms[0].elements[i].checked=true;
}
}
}
}
//取消选择
function GVSelectCancel(){
var len=document.forms[0].elements.length;
var i;
for (i=0;i<len;i++){
if (document.forms[0].elements[i].type=="checkbox" && document.forms[0].elements[i].name.indexOf("GridViewID")>-1){
document.forms[0].elements[i].checked = false;
}
}
}
//GirdView选择一条记录进行操作前的确认
function GVSelectOneConfirm(){
var selectCount = 0;
for(i=0; i<document.forms[0].elements.length;i++){
if(document.forms[0].elements[i].type=="checkbox" && document.forms[0].elements[i].name.indexOf("GridViewID")>-1 && document.forms[0].elements[i].checked) selectCount++;
}
if(selectCount<1){
alert("请勾选一条数据,然后再点击按钮进行操作!");
return false;
}else if(selectCount>1){
alert("只能同时操作一条数据,请检查你是否勾选了多条数据!");
return false;
}else{
return true;
}
return false;
}
//GridView选择一条记录进行操作前的确认,确认提示信息由用户自定义
function GVSelectOneConfirmByParm(str){
var selectCount = 0;
for(i=0; i<document.forms[0].elements.length;i++){
if(document.forms[0].elements[i].type=="checkbox" && document.forms[0].elements[i].name.indexOf("GridViewID")>-1 && document.forms[0].elements[i].checked) selectCount++;
}
if(selectCount<1){
alert("请勾选一条数据,然后再点击按钮进行操作!");
return false;
}else if(selectCount>1){
alert("只能同时操作一条数据,请检查你是否勾选了多条数据!");
return false;
}else{
return confirm(str);
}
return false;
}
//GridView选择一条或多条记录进行操作前,判断是否选择了记录
function GVSelectOneOrMore(){
var selectCount = 0;
for(i=0; i<document.forms[0].elements.length;i++){
if(document.forms[0].elements[i].type=="checkbox" && document.forms[0].elements[i].name.indexOf("GridViewID")>-1 && document.forms[0].elements[i].checked) selectCount++;
}
if(selectCount<1){
alert("请至少勾选一条数据,然后再点击按钮进行操作!");
return false;
}
return true;
}
//GridView最少必须保留一项
function GVUnSelectOne(){
var selectCount = 0;
var rowCount = 0;
for(i=0; i<document.forms[0].elements.length;i++){
if(document.forms[0].elements[i].type=="checkbox" && document.forms[0].elements[i].name.indexOf("GridViewID")>-1 )
{
rowCount++;
if(document.forms[0].elements[i].checked)
selectCount++;
}
}
if(selectCount<1){
alert("请至少勾选一条数据,然后再点击按钮进行操作!");
return false;
}
if(selectCount==rowCount)
{
alert("最少必须保留一条数据!");
return false;
}
return true;
}
//GridView选择一条或多条记录进行操作前的确认
function GVSelectOneOrMoreConfirm(){
var selectCount = 0;
for(i=0; i<document.forms[0].elements.length;i++){
if(document.forms[0].elements[i].type=="checkbox" && document.forms[0].elements[i].name.indexOf("GridViewID")>-1 && document.forms[0].elements[i].checked) selectCount++;
}
if(selectCount<1){
alert("请至少勾选一条数据,然后再点击按钮进行操作!");
return false;
}else{
return confirm("删除后数据将不能恢复,你确定要删除数据吗?");
}
return false;
}
//GridView选择一条或多条记录进行操作前的确认-合同过账
function GVSelectOneOrMoreConfirm_Posting(){
var selectCount = 0;
for(i=0; i<document.forms[0].elements.length;i++){
if(document.forms[0].elements[i].type=="checkbox" && document.forms[0].elements[i].name.indexOf("GridViewID")>-1 && document.forms[0].elements[i].checked) selectCount++;
}
if(selectCount<1){
alert("请至少勾选一条数据,然后再点击按钮进行操作!");
return false;
}else{
return confirm("确定要对所选合同过账吗?");
}
return false;
}
//GridView选择一条或多条记录进行操作前的确认-企业分配
function GVSelectOneOrMoreConfirm_Assign() {
var selectCount = 0;
for (i = 0; i < document.forms[0].elements.length; i++) {
if (document.forms[0].elements[i].type == "checkbox" && document.forms[0].elements[i].name.indexOf("GridViewID") > -1 && document.forms[0].elements[i].checked) selectCount++;
}
if (selectCount < 1) {
alert("请至少勾选一条数据,然后再点击按钮进行操作!");
return false;
}
return false;
}
//GridView选择一条或多条记录进行操作前的确认
function GVSelectOneOrMore(){
var selectCount = 0;
for(i=0; i<document.forms[0].elements.length;i++){
if(document.forms[0].elements[i].type=="checkbox" && document.forms[0].elements[i].name.indexOf("GridViewID")>-1 && document.forms[0].elements[i].checked) selectCount++;
}
if(selectCount<1){
alert("请至少勾选一条数据,然后再点击按钮进行操作!");
return false;
}else{
return true;
}
return false;
}
//GridView选择一条或多条记录进行操作前的确认,确认提示信息由用户自定义
function GVSelectOneOrMoreConfirmByParm(str){
var selectCount = 0;
for(i=0; i<document.forms[0].elements.length;i++){
if(document.forms[0].elements[i].type=="checkbox" && document.forms[0].elements[i].name.indexOf("GridViewID")>-1 && document.forms[0].elements[i].checked) selectCount++;
}
if(selectCount<1){
alert("请至少勾选一条数据,然后再点击按钮进行操作!");
return false;
}else{
return confirm(str);
}
return false;
}
function confirmMsg (){
j = 0;
for (i=0; i<document.forms[0].length; i++){
if (document.forms[0].elements[i].name.indexOf("checkbox") !=-1){
if(document.forms[0].elements[i].checked){
j++;
return confirm ('删除后数据将不能恢复,你确定要删除数据吗?')
}
}
}
if (j == 0){
alert ("请至少勾选一条数据,然后再点击按钮进行操作!");
return false;
}
}
//去除两头空格
function trim(str)
{
var str1 = str.replace(/^/s+|/s+$/g, "");
return str1;
}
//给String类加上trim()方法,去掉前后空格
String.prototype.trim = function()
{
return this.replace(/(^/s*)|(/s*$)/g, "");
}
//getPageSize函数返回一个数组,前两个是整个页面的宽度和高度,后两个是页面窗口的宽度和高度
function getPageSize(varWindow)
{
var xScroll, yScroll;
if (varWindow.innerHeight && varWindow.scrollMaxY)
{
xScroll = varWindow.document.body.scrollWidth;
yScroll = varWindow.innerHeight + varWindow.scrollMaxY;
}
else if (varWindow.document.body.scrollHeight > varWindow.document.body.offsetHeight)
{
xScroll = varWindow.document.body.scrollWidth;
yScroll = varWindow.document.body.scrollHeight;
}
else
{
xScroll = varWindow.document.body.offsetWidth;
yScroll = varWindow.document.body.offsetHeight;
}
var windowWidth, windowHeight;
if (varWindow.innerHeight)
{
windowWidth = varWindow.innerWidth;
windowHeight = varWindow.innerHeight;
}
else if (varWindow.document.documentElement && varWindow.document.documentElement.clientHeight)
{
windowWidth = varWindow.document.documentElement.clientWidth;
windowHeight = varWindow.document.documentElement.clientHeight;
}
else if (varWindow.document.body)
{
windowWidth = varWindow.document.body.clientWidth;
windowHeight = varWindow.document.body.clientHeight;
}
if (yScroll < windowHeight)
{
pageHeight = windowHeight;
}
else
{
pageHeight = yScroll;
}
if (xScroll < windowWidth)
{
pageWidth = windowWidth;
}
else
{
pageWidth = xScroll;
}
arrayPageSize = new Array(pageWidth, pageHeight, windowWidth, windowHeight);
return arrayPageSize;
}
//getScrollTop函数获得当前页面的滚动条纵坐标位置。在给页面添加了
//<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
//后,document.body.scrollTop永远等于0。此时可以用这个方法来获得scrollTop。
function getScrollTop()
{
if (typeof window.pageYOffset != 'undefined')
{
return window.pageYOffset;
}
else if (typeof document.compatMode != 'undefined' && document.compatMode != 'BackCompat')
{
return document.documentElement.scrollTop;
}
else if (typeof document.body != 'undefined')
{
return document.body.scrollTop;
}
}
//设置按钮是否显示,visible为true时显示,否则不显示,id为要设置的按钮id
function setButtonVisible(id,visible)
{
var space = document.getElementById(id+"_Space");
if(space!=null){
space.style.display = visible==true?"":"none";
}
var button = document.getElementById(id);
if(button!=null){
button.style.display = visible==true?"":"none";
}
}
// 自适应iframe调度
function autoresetIframeHeight() {
if (parent.document.all["IframeContent"] != null) {
//parent.document.all["IframeContent"].style.width = document.body.scrollWidth;
parent.document.all["IframeContent"].style.height = document.body.scrollHeight + 20;
}
if (parent.document.all["IframeContent"] != null) {
//parent.document.all["IframeContent"].style.width = document.body.scrollWidth;
parent.document.all["IframeContent"].style.height = document.body.scrollHeight + 20;
}
}