share.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. // JavaScript Document
  2. //Cookie
  3. function SetCookie(name,value)//两个参数,一个是cookie的名子,一个是值
  4. {
  5. var Days = 0; //此 cookie 将被保存 30 天
  6. var exp = new Date(); //new Date("December 31, 9998");
  7. exp.setTime(exp.getTime() + Days*24*60*60*1000);
  8. document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString() + ";"
  9. }
  10. function getCookie(name)//取cookies函数
  11. {
  12. var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
  13. if(arr != null)
  14. return unescape(arr[2]);
  15. else
  16. return 1;
  17. }
  18. //correctPNG
  19. function correctPNG()
  20. {
  21. for(var i=0; i<document.images.length; i++)
  22. {
  23. var img = document.images[i];
  24. var imgName = img.src.toUpperCase();
  25. if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
  26. {
  27. var imgID = (img.id) ? "id='" + img.id + "' " : "";
  28. var imgClass = (img.className) ? "class='" + img.className + "' " : "";
  29. var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' ";
  30. var imgStyle = "display:inline-block;" + img.style.cssText;
  31. if (img.align == "left") imgStyle = "float:left;" + imgStyle;
  32. if (img.align == "right") imgStyle = "float:right;" + imgStyle;
  33. if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle;
  34. var strNewHTML = "<span " + imgID + imgClass + imgTitle
  35. + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
  36. + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
  37. + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>";
  38. img.outerHTML = strNewHTML;
  39. i = i-1;
  40. }
  41. }
  42. }
  43. function alphaBackgrounds(){
  44. var rslt = navigator.appVersion.match(/MSIE (d+.d+)/, '');
  45. var itsAllGood = (rslt != null && Number(rslt[1]) >= 5.5);
  46. for (i=0; i<document.all.length; i++){
  47. var bg = document.all[i].currentStyle.backgroundImage;
  48. if (bg){
  49. if (bg.match(/.*\.png.*/i) != null){
  50. var mypng = bg.substring(5,bg.length-2);
  51. document.all[i].style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+mypng+"', sizingMethod='scale')";
  52. document.all[i].style.backgroundImage = "url('')";
  53. }
  54. }
  55. }
  56. }
  57. if (navigator.platform == "Win32" && navigator.appName == "Microsoft Internet Explorer" && window.attachEvent) {
  58. window.attachEvent("onload", correctPNG);
  59. window.attachEvent("onload", alphaBackgrounds);
  60. }
  61. function CheckItem(CB){
  62. var tagname=(arguments.length>1)?arguments[1]:'TR';
  63. if(document.myform.chkAll.checked){
  64. document.myform.chkAll.checked = document.myform.chkAll.checked&0;
  65. }
  66. if (CB.checked){hL(CB,tagname)};else{dL(CB,tagname)};
  67. var TB=TO=0;
  68. for (var i=0;i<myform.elements.length;i++) {
  69. var e=myform.elements[i];
  70. if ((e.name != 'chkAll') && (e.type=='checkbox')) {
  71. TB++;
  72. if (e.checked) TO++;
  73. }
  74. }
  75. myform.chkAll.checked=(TO==TB)?true:false;
  76. }
  77. function CheckAll(form){
  78. var tagname=(arguments.length>1)?arguments[1]:'TR';
  79. for (var i=0;i<form.elements.length;i++){
  80. var e = form.elements[i];
  81. if (e.name != 'chkAll' && e.disabled == false && e.type == 'checkbox') {
  82. e.checked = form.chkAll.checked;
  83. if (e.checked){hL(e,tagname)};else{dL(e,tagname)};
  84. }
  85. }
  86. }
  87. function hL(E,tagname){
  88. while (E.tagName!=tagname) {E=E.parentElement;}
  89. }
  90. function dL(E,tagname){
  91. while (E.tagName!=tagname) {E=E.parentElement;}
  92. }
  93. function Del(){
  94. if(document.myform.Action.value=='ConfirmDel'){
  95. if(confirm('确定要删除选中的区域吗?删除后将不能恢复!'))
  96. return true;
  97. else
  98. return false;
  99. }
  100. }