首页 >web前端 >js教程 >脚本吧 - 幻宇工作室用到js,超强推荐expand.js_javascript技巧

脚本吧 - 幻宇工作室用到js,超强推荐expand.js_javascript技巧

WBOY
WBOY原创
2016-05-16 19:22:331043浏览
复制代码 代码如下:

function createDlg(dlgID,title,w,h,isSetPos){
    var l,i,p,dlg
    if($(dlgID)!=null)
        $(dlgID).outerHTML=""
    $sys.dlgDepth=($sys.dlgDepth||9000)
    l="
"
    l+=""
    for(i=0;i<3;i++){
p=i==0?"t":(i==1?"m":"b")
l+=""
    }
    l+="
"
        l+=""
        l+=""
        l+=""
        l+="
"
    l+="
"+(title||"")+"  
"
    l+=""
    l+=""
    l+="
"
    insHtm(document.body,l)
    dlg=$(dlgID)
    focuDlg(dlg)
    dlg.onselectstart=dlg.onmousedown=dlg.ondragstart=dlg.oncontextmenu=function( e){
        var ee
        e=e||事件
        ee=e.srcElement
        if(isSetPos&&e.type=="mousedown"&&isIE)
            window.clipboardData.设置数据(“文本",($x(ee,this) e.offsetX) "," ($y(ee,this) e.offsetY))
        if(ee.tagName!="INPUT"&&ee.tagName!=" TEXTAREA")
            返回 false
        if(ee.readOnly==true)
            返回 false
    }
}
function focuDlg(dlg){
    dlg=$ (dlg )
    if($sys.currentDlg==dlg)
        return
    $sys.dlgDepth
    dlg.style.zIndex=$sys.dlgDepth
    $sys.currentDlg=dlg
}
函数 fmCheck(fm){
    var ar=[],$caption,$checkRule,$value,sTip,i,j,$n
    ar.push(["notnull","$ value==''","$caption不能为空!"])
    ar.push(["uid","!/^[_a-zA-Z0-9\u4E00-\u9FA5\uF900-\ uFA2D]{2,16}$/.test($value)","昵称只能由2到16个汉字、英文、数字或下划线组成!"])
    ar.push(["pwd", "!/^[_a-zA-Z0-9]{6,12}$/.test($value)","密码只能由6到12个英文、数字或下划线组成!"])
ar.push(["cpwd","fm[i].value!=fm[i-1].value","密码确认不一致!"])
    ar.push(["eml","! /^([\w-\.] )@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3} \.)|(([\w-] \.) ))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/.test ($value)","邮箱格式不正确!"])
    ar.push(["max-","$n=/max\-(\d )/.exec($checkRule)[1] *1;$value.length>$n","$caption最多只能输入$n个字符!"])
    ar.push(["min-","$n=/min\-(\ d )/.exec($checkRule)[1]*1;$value.length
    for(i=0;i        $caption=fm[i].getAttribute("caption")
        $checkRule=fm[i ].getAttribute("checkRule")
        if($checkRule==null)
            继续
        $value=fm[i].value=fm[i].value.trim()
         for (j=0;j            if(new RegExp("\b" ar[j][0] "\b").test($checkRule)&&eval(ar[j] [1])){
                sTip=fm[i].getAttribute("tip_" ar[j][0])
               if(sTip==null)
                    sTip=ar[j][2 ].replace(/$w /g,function($0){return eval($0)})
                alert(sTip)
                oFocu(fm[i])
                return false
            }
        }
    }
    返回 true
}
函数 editor_paste(w,html){
    if(document.all)
        w.document.selection.createRange().pasteHTML( html)
    else{
        var ol,i,r=w.document.createRange()
        w.document.execCommand("insertimage",false,"http://temp_obj/")
        ol=w.document.getElementsByTagName("img")
        for(i=0;i            if(ol[i].src=="http://temp_obj /"){
                r.setStartBefore(ol[i])
               ol[i].parentNode.insertBefore(r.createContextualFragment(html),ol[i])
                ol[i].parentNode. removeChild(ol[i])
            }
        }
    }
}
function editor_getVal(win){
    var sContent
    尝试{
        sContent=win .文档.body.innerHTML
        sContent=sContent.replace(/]*>[^>]*>/gi,"")
    }
    catch(e) {
        sContent=""
    }
    sContent=sContent.trim()
    return sContent
}

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn