dialog.js.bak 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. // 取通过URL传过来的参数 (格式如 ?Param1=Value1&Param2=Value2)
  2. var URLParams = new Object() ;
  3. var aParams = document.location.search.substr(1).split('&') ;
  4. for (i=0 ; i < aParams.length ; i++) {
  5. var aParam = aParams[i].split('=') ;
  6. URLParams[aParam[0]] = aParam[1] ;
  7. }
  8. // 具有主窗口相同的配置信息
  9. var config;
  10. try{
  11. config = dialogArguments.config;
  12. }
  13. catch(e){
  14. }
  15. // 去空格,left,right,all可选
  16. function BaseTrim(str){
  17. lIdx=0;rIdx=str.length;
  18. if (BaseTrim.arguments.length==2)
  19. act=BaseTrim.arguments[1].toLowerCase()
  20. else
  21. act="all"
  22. for(var i=0;i<str.length;i++){
  23. thelStr=str.substring(lIdx,lIdx+1)
  24. therStr=str.substring(rIdx,rIdx-1)
  25. if ((act=="all" || act=="left") && thelStr==" "){
  26. lIdx++
  27. }
  28. if ((act=="all" || act=="right") && therStr==" "){
  29. rIdx--
  30. }
  31. }
  32. str=str.slice(lIdx,rIdx)
  33. return str
  34. }
  35. // 基本信息提示,得到焦点并选定
  36. function BaseAlert(theText,notice){
  37. alert(notice);
  38. theText.focus();
  39. theText.select();
  40. return false;
  41. }
  42. // 是否有效颜色值
  43. function IsColor(color){
  44. var temp=color;
  45. if (temp=="") return true;
  46. if (temp.length!=7) return false;
  47. return (temp.search(/\#[a-fA-F0-9]{6}/) != -1);
  48. }
  49. // 只允许输入数字
  50. function IsDigit(){
  51. return ((event.keyCode >= 48) && (event.keyCode <= 57));
  52. }
  53. // 选颜色
  54. function SelectColor(what){
  55. var dEL = document.all("d_"+what);
  56. var sEL = document.all("s_"+what);
  57. var url = "selcolor.htm?color="+encodeURIComponent(dEL.value);
  58. var arr = showModalDialog(url,window,"dialogWidth:280px;dialogHeight:250px;help:no;scroll:no;status:no");
  59. if (arr) {
  60. dEL.value=arr;
  61. sEL.style.backgroundColor=arr;
  62. }
  63. }
  64. // 选背景图
  65. function SelectImage(){
  66. showModalDialog("backimage.htm?action=other",window,"dialogWidth:350px;dialogHeight:210px;help:no;scroll:no;status:no");
  67. }
  68. // 搜索下拉框值与指定值匹配,并选择匹配项
  69. function SearchSelectValue(o_Select, s_Value){
  70. for (var i=0;i<o_Select.length;i++){
  71. if (o_Select.options[i].value == s_Value){
  72. o_Select.selectedIndex = i;
  73. return true;
  74. }
  75. }
  76. return false;
  77. }
  78. // 转为数字型,并无前导0,不能转则返回""
  79. function ToInt(str){
  80. str=BaseTrim(str);
  81. if (str!=""){
  82. var sTemp=parseFloat(str);
  83. if (isNaN(sTemp)){
  84. str="";
  85. }else{
  86. str=sTemp;
  87. }
  88. }
  89. return str;
  90. }
  91. // 是否有效的链接
  92. function IsURL(url){
  93. var sTemp;
  94. var b=true;
  95. sTemp=url.substring(0,7);
  96. sTemp=sTemp.toUpperCase();
  97. if ((sTemp!="HTTP://")||(url.length<10)){
  98. b=false;
  99. }
  100. return b;
  101. }
  102. // 是否有效的扩展名
  103. function IsExt(url, opt){
  104. var sTemp;
  105. var b=false;
  106. var s=opt.toUpperCase().split("|");
  107. for (var i=0;i<s.length ;i++ ){
  108. sTemp=url.substr(url.length-s[i].length-1);
  109. sTemp=sTemp.toUpperCase();
  110. s[i]="."+s[i];
  111. if (s[i]==sTemp){
  112. b=true;
  113. break;
  114. }
  115. }
  116. return b;
  117. }
  118. // 取完整链接
  119. function GetHttpUrl(url){
  120. if (url.substring(0,1)=="/"){
  121. return (document.location.protocol + '//' + document.location.host + url);
  122. }
  123. var sURL=document.URL;
  124. //modify by zxl 10100427
  125. alert(sURL.substring(0,sURL.lastIndexOf("/eWebEditor/dialog/")+1)+url);
  126. return sURL.substring(0,sURL.lastIndexOf("/eWebEditor/dialog/")+1)+url;
  127. //return sURL.substring(0,sURL.lastIndexOf("/dialog/")+1)+url;
  128. ////modify by zxl end
  129. }