global.js
上传用户:zhouquan
上传日期:2021-05-12
资源大小:16497k
文件大小:2k
源码类别:

WEB源码(ASP,PHP,...)

开发平台:

HTML/CSS

  1. // JavaScript Document
  2. function $(id) {
  3. return document.getElementById(id);
  4. }
  5. function Roly() {}
  6. function AutoFrameHeight(name,def) {
  7. var iframe = document.getElementById(name);
  8. if(def == undefined)
  9. def = 280; //set default height
  10. if(iframe.readyState == "complete") {
  11. var height = eval(name).document.body.scrollHeight;
  12. if(height<def)
  13. height = def;
  14. height += 30;
  15. iframe.style.height=height+"px";
  16. }
  17. }
  18. function forward(URLStr) {
  19. window.location = URLStr;
  20. }
  21. function parentforward(URLStr) {
  22. self.parent.location = URLStr;
  23. }
  24. //日期差值
  25. Date.prototype.DayDiff = function(cDate,mode){
  26. try{
  27. cDate.getYear();
  28. }catch(e){
  29. return(0);
  30. }
  31. var base =60*60*24*1000;
  32. var result = Math.abs(this.getTime() - cDate.getTime());
  33. switch(mode){
  34. case "y":
  35. result/=base*365;
  36. break;
  37. case "m":
  38. result/=base*365/12;
  39. break;
  40. case "w":
  41. result/=base*7;
  42. break;
  43. default:
  44. result/=base;
  45. break;
  46. }
  47. return(Math.floor(result));
  48. }
  49. //打开加载窗口
  50. function callLoadingBox(button,left,top) {
  51. var loadDiv = document.createElement("div");
  52. loadDiv.id = "loadDiv";
  53. loadDiv.className = "load";
  54. loadDiv.appendChild(document.createTextNode("加载中,请稍等"));
  55. if(left!=null && top!=null) {
  56. loadDiv.style.left = left;
  57. loadDiv.style.top = top;
  58. }
  59. document.body.appendChild(loadDiv);
  60. if(button!=null) {
  61. button.disabled = true;
  62. }
  63. }
  64. function getCookie(name) {
  65. var re = "(?:; )?"+name+"=([^;]*);?";
  66. var oRE = new RegExp(re);
  67. if(oRE.test(document.cookie)) {
  68. return decodeURIComponent(RegExp["$1"]);
  69. }else{
  70. return null;
  71. }
  72. }
  73. function AutomateExcel(table) {
  74. // Start Excel and get Application object.
  75. try {
  76. var oXL = new ActiveXObject("Excel.Application"); 
  77. // Get a new workbook.
  78. var oWB = oXL.Workbooks.Add();
  79. var oSheet = oWB.ActiveSheet;
  80. var sel=document.body.createTextRange();
  81.    sel.moveToElementText(table);
  82.    sel.select();
  83.    sel.execCommand("Copy");
  84.    oSheet.Paste();
  85.    oXL.Visible = true;
  86. oXL.Visible = true;
  87. oXL.UserControl = true;
  88. } catch (e) {
  89. alert("请确定已安装Excel2000,IE6.0(或更高版本),并且IE安全设置中对ActiveX控件设置为启用!");
  90. }
  91. }
  92. function setChineseCode(source) {
  93. return encodeURI(source);
  94. }