⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 public.js

📁 J2EE技术开发的新闻发布系统。包括:分类管理、新闻管理、用户管理等基本功能.采用了Client
💻 JS
字号:
//get an object by the id
function findObject(id, doc) {//from macromedia
  var p,i,x;
  if(!doc) doc=document;
  if((p=id.indexOf("?"))>0&&parent.frames.length) {
    doc=parent.frames[id.substring(p+1)].document;
    id=id.substring(0,p);
  }
  if(!(x=doc[id])&&doc.all) x=doc.all[id];
  for (i=0;!x&&i<doc.forms.length;i++)
      x=doc.forms[i][id];
  for(i=0;!x&&doc.layers&&i<doc.layers.length;i++)
      x=findObj(id,doc.layers[i].document);
  if(!x && doc.getElementById)
      x=doc.getElementById(id);
  
  return x;
}

//get an object list by a same name
function findObjectListByName(name, doc){
  var list;
  if(!doc) doc = document;
  
	if(!doc.all){
    list = doc.getElementsByName(name);
  }
  else{
    list = new Array();
    var count = 0;
    for(var i = 0; i < doc.all.length; i++){
      var element = doc.all[i];
      if(element.name == name){
        list[count] = element;
        count++;
      }
    }
  }
  return list;
}



//get an object list by a same tag name
function findObjectListByTag(name, doc){
  var list;
  if(!doc) doc = document;
  
	if(doc.all){
    list = doc.all.tags(name);
  }
  else{
    list = doc.getElementsByTagName(name);
  }
  return list;
}



/**
  open a modal dialog window
*/
function openModal(url, width, height){
  var sFeatures = "dialogWidth:"+ width + "px;dialogHeight: " + height + "px;scroll:no";
  return window.showModalDialog(url, "", sFeatures);
}


/**
  open a popup window
  usage:
  openWindow("page.html", "newwindow", 200, 300,
             "toolbar=no, menubar=no, scrollbars=no,resizable=no,location=no, status=no");
*/
function openWindow(url, windowID, height, width, otherParam){
  var param = "";
  
  //height and top
  if(height == null || isNaN(height) || height <= 0){
    param += "height=, top=,";
  }
  else{
    var top = (screen.availHeight - height) / 2;
    param += "height=" + height + ", top=" + top + ",";
  }
  
  //width and left
  if(width == null || isNaN(width) || width <= 0){
    param += "width=, left=,";
  }
  else{
    var left = (screen.availWidth - width) / 2;
    param += "width=" + width + ", left=" + left + ",";
  }
  
  if(otherParam == null || otherParam == ""){
    otherParam = "toolbar=no, menubar=no, scrollbars=no,resizable=no,location=no, status=no";
  }

  window.open(url, windowID, param + otherParam);
}

//Make a string as a tag
function markTag(str){
  return "<" + str + ">"
}


//show a debug message
function debug(msg){
  if(isDebug)
    alert("==DEBUG==\n" + msg);
}

//show a error message
function err(msg){
  alert("!!ERROR!!\n" + msg);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -