common.js
上传用户:jhtang88
上传日期:2014-01-27
资源大小:28528k
文件大小:3k
源码类别:

Jsp/Servlet

开发平台:

Java

  1. function $(s){return document.getElementById(s);}
  2. function $$(s){return document.frames?document.frames[s]:$(s).contentWindow;}
  3. function $c(s){return document.createElement(s);}
  4. function exist(s){return $(s)!=null;}
  5. function dw(s){document.write(s);}
  6. function hide(s){$(s).style.display=$(s).style.display=="none"?"":"none";}
  7. function isNull(_sVal){return (_sVal == "" || _sVal == null || _sVal == "undefined");}
  8. function isIE(){return BROWSER.indexOf('ie') > -1;}
  9. function detectBrowser(){
  10. var sUA = navigator.userAgent.toLowerCase();
  11. var sIE = sUA.indexOf("msie");
  12. var sOpera = sUA.indexOf("opera");
  13. var sMoz = sUA.indexOf("gecko");
  14. if (sOpera != -1) return "opera";
  15. if (sIE != -1){
  16. nIeVer = parseFloat(sUA.substr(sIE + 5));
  17. if (nIeVer >= 6) return "ie6";
  18. else if (nIeVer >= 5.5) return "ie55";
  19. else if (nIeVer >= 5 ) return "ie5";
  20. }
  21. if (sMoz != -1) return "moz";
  22. return "other";
  23. }
  24. function getRadioValue(radionname) {
  25. var radioboxs = document.all.item(radionname);
  26. if (radioboxs!=null)
  27. {
  28. for (i=0; i<radioboxs.length; i++)
  29. {
  30. if (radioboxs[i].type=="radio" && radioboxs[i].checked)
  31. return radioboxs[i].value;
  32. }
  33. }
  34. return radioboxs.value
  35. }
  36. return "";
  37. }
  38. function setRadioValue(myitem, v)
  39. {
  40.      var radioboxs = document.all.item(myitem);
  41.      if (radioboxs!=null)
  42.      {
  43.        for (i=0; i<radioboxs.length; i++)
  44.           {
  45.             if (radioboxs[i].type=="radio")
  46.               {
  47.                  if (radioboxs[i].value==v)
  48.   radioboxs[i].checked = true;
  49.               }
  50.           }
  51.      }
  52. }
  53. function getCheckboxValue(checkboxname){
  54. var checkboxboxs = document.all.item(checkboxname);
  55. var CheckboxValue = '';
  56. if (checkboxboxs!=null)
  57. {
  58. // 如果只有一个元素
  59. if (checkboxboxs.length==null) {
  60. if (checkboxboxs.checked) {
  61. return checkboxboxs.value;
  62. }
  63. }
  64. for (i=0; i<checkboxboxs.length; i++)
  65. {
  66. if (checkboxboxs[i].type=="checkbox" && checkboxboxs[i].checked)
  67. {
  68. if (CheckboxValue==''){
  69. CheckboxValue += checkboxboxs[i].value;
  70. }
  71. else{
  72. CheckboxValue += ","+ checkboxboxs[i].value;
  73. }
  74. }
  75. }
  76. }
  77. return CheckboxValue;
  78. }
  79. function setCheckboxChecked(checkboxname, v) {
  80. var checkboxboxs = document.all.item(checkboxname);
  81. if (checkboxboxs!=null)
  82. {
  83. // 如果只有一个元素
  84. if (checkboxboxs.length==null) {
  85. if (checkboxboxs.value == v) {
  86. checkboxboxs.checked = true;
  87. }
  88. }
  89. for (i=0; i<checkboxboxs.length; i++)
  90. {
  91. if (checkboxboxs[i].type=="checkbox" && checkboxboxs[i].value == v)
  92. {
  93. checkboxboxs[i].checked = true;
  94. }
  95. }
  96. }
  97. }
  98. function isNumeric(str) {
  99. if (str==null || str=="")
  100. return false;
  101. return !isNaN(str);
  102. }
  103. function isNotCn(str) {
  104. if (/[^x00-xff]/g.test(str))
  105. return false;
  106. else
  107. return true;
  108. }