Script-the studio uses js, which is strongly recommended for base. js.

Source: Internet
Author: User

Base. js Copy codeThe Code is as follows: browser_init ()
Function browser_init (){
Window. isIE = navigator. appName. indexOf ("Microsoft") = 0
Window. $ sys = {}
Window. $ my = {}
String. prototype. trim = function () {return this. replace (/(^ [\ s] *) | ([\ s] * $)/g ,"")}
String. prototype. inc = function (s1, s2) {if (s2 = null) {s2 = ","}; return (s2 + this + s2 ). indexOf (s2 + s1 + s2)>-1? 1:0}
String. prototype. lenB = function () {return this. replace (/[^ \ x00-\ xff]/g, "**"). length}
String. prototype. leftB = function (len, isOmit) {var s; s = this. replace (/\ */g ,""). replace (/[^ \ x00-\ xff]/g, "**"); if (s. length> len & isOmit) {len-= 3}; return this. slice (0, s. slice (0, len ). replace (/\ */g ,""). replace (/\ */g ,""). length) + (s. length> len & isOmit? "...":"")}
String. prototype. getVar = function (str, def) {if (this. inc (str, ";") return 1; var a = this. match (new RegExp ("(^ |;)" + str + ": [^;] *"); return a = null | str = ""? (Def = null? "": Def): a [0]. replace (";", ""). slice (str. length + 1 )}
String. prototype. _ slice = "". slice
String. prototype. slice = function (n1, n2) {var v, b1 = typeof (n1) = "number", b2 = typeof (n2) = "number"; if (! B1 | typeof (n2) = "string") {v = eval ("this. _ slice (" + (b1? N1: this. indexOf (n1) + (n2 = null? 1:0) + (this. indexOf (n1) =-1? This. length: 0) + (n2 = null? "" :( B2? N2 :( this. indexOf (n2) =-1? "": "," + This. indexOf (n2) + ")} else {v = eval (" this. _ slice (n1 "+ (n2 = null? "": "," + N2) + ")")} return v}
Array. prototype. parseInt = function () {var I, count = this. length; for (I = 0; I <count; I ++) {this [I] = parseInt (this [I])}
Array. prototype. remove = function (item) {var I, count = this. length; for (I = 0; I <count; I ++) {if (this [I] = item) {this. splice (I, 1); I --; count --}}}
Array. prototype. plus = function (item) {for (var I = 0; I <this. length; I ++) {if (this [I] = item) {return} this. push (item )}
Window. $ = function (obj) {return typeof (obj) = "string "? Document. getElementById (obj): obj}
Window. ow = function (win) {return $ (win). contentWindow}
Window. oDel = function (obj) {if ($ (obj )! = Null) {$ (obj). parentNode. removeChild ($ (obj ))}}
Window. oHide = function (obj) {if ($ (obj )! = Null) {$ (obj). style. visibility = "hidden "}}
Window. oShow = function (obj) {if ($ (obj )! = Null) {$ (obj). style. visibility = ""}}
Window. oFocu = function (obj) {window. tempObj = $ (obj); window. setTimeout ("try {window. tempObj. focus ()} catch (e) {}", 10 )}
Window. fmCheck = function () {return true}

$ Sys. url = location. href
$ Sys. path = $ sys. url. slice (0 ,"? "). Slice (0, $ sys. url. lastIndexOf ("/") + 1)
Document. write ("<body> </body> ")
If (document. all ){
Document.exe cCommand ("BackgroundImageCache", false, true)
}
Else {
HTMLElement. prototype. attachEvent = function (type, foo) {this. addEventListener (type. slice (2), foo, false )}
HTMLElement. prototype. contains = function (node) {if (! Node) return false; do if (node = this) {return true} while (node = node. parentNode) {return false }}
HTMLElement. prototype. _ defineSetter _ ("outerHTML", function (sHTML) {var r = this. ownerDocument. createRange (); r. setStartBefore (this); var df = r. createContextualFragment (sHTML); this. parentNode. replaceChild (df, this); return sHTML ;})
HTMLElement. prototype. _ defineGetter _ ("innerText", function () {var r = this. ownerDocument. createRange (); r. selectNodeContents (this); return r. toString ()})
Event. prototype. _ defineGetter _ ("srcElement", function () {var node1_this.tar get; while (node. nodeType! = 1) {node = node. parentNode} return node })
Event. prototype. _ defineGetter _ ("fromElement", function () {return this. relatedTarget })
Event. prototype. _ defineGetter _ ("toElement", function () {return this. relatedTarget })
Event. prototype. _ defineGetter _ ("offsetX", function () {return this. layerX })
Event. prototype. _ defineGetter _ ("offsetY", function () {return this. layerY })
}
Drag_init ()
Thd_init ()
Document_onload ()
}
Function document_onload (){
Var l
L = "<div id = mcSystem style = 'position: absolute; left:-9000px; top: 0'>"
L + = "<iframe id = wForm name = wForm onload = fmWinOnLoad (this)> </iframe>"
L + = "<button id = btSysFocu> </button>"
L + = "</div>"
InsHtm (document. body, l)
Document. body. onmouseover = document. body. onmouseout = document. body. onmousedown = document. body. onmouseup = function (e ){
Var ee
E = e | event
Ee = e. srcElement
If (e. type = "mouseover" & (ee. tagName = "A" | ee. tagName = "INPUT" | ee. tagName = "LABEL ")&&! Ee. hideFocus)
Ee. hideFocus = true
}
Document. body. onkeydown = function (e ){
Var ee
E = e | event
Ee = e. srcElement
If (ee. tagName = "INPUT" & e. keyCode = 13 & isIE & ee. form! = Null ){
If (ee. form. btSubmit! = Null)
Ee. form. btSubmit. click ()
}
}
If (window. body_onload! = Null)
Body_onload ()
}
Function drag_init (){
Window. $ drag = {}
Window. startDrag = function (obj, e ){
$ Drag. obj = $ (obj)
$ Drag. x0 = $ drag. obj. offsetLeft
$ Drag. y0 = $ drag. obj. offsetTop
$ Drag. sx = e. clientX
$ Drag. sy = e. clientY
If (document. all)
$ Drag. obj. setCapture ()
}
Document. onmouseup = function (){
If ($ drag. obj = null)
Return
If (document. all)
$ Drag. obj. releaseCapture ()
$ Drag. obj = null
}
Document. onmousemove = function (e ){
Var x, y
If ($ drag. obj = null)
Return
E = e | event
X = Math. min (e. clientX-$ drag. sx + $ drag. x0, document. body. scrollLeft + document. body. clientWidth-$ drag. obj. offsetWidth)
Y = Math. min (e. clientY-$ drag. sy + $ drag. y0, document. body. scrollTop + document. body. clientHeight-$ drag. obj. offsetHeight)
X = Math. max (x, 0)
Y = Math. max (y, document. body. scrollTop)
$ Drag. obj. style. left = x + "px"
$ Drag. obj. style. top = y + "px"
}
}
Function thd_init (){
Window. $ thd = {}
$ Thd. items = []
$ Thd. index = 0
$ Thd. push = function (foo, interval ){
Foo. interval = null? 1: interval
$ Thd. items. push (foo)
}
$ Thd. remove = function (foo ){
$ Thd. items. remove (foo)
}
$ Thd. run = function (){
Var ol = $ thd. items, I
For (I = 0; I <ol. length; I ++ ){
If ($ thd. index % ol [I]. interval = 0 | ol [I]. start = null ){
Ol [I]. start = 1
Ol [I] ()
}
}
$ Thd. index ++
Window. setTimeout ("$ thd. run ()", 10)
}
$ Thd. run ()
}
Function $ x (obj, op ){
Var o, x = 0
Op = op | document. body
Do {
O = null? $ (Obj): o. parentNode
If (op = o)
Break
X + = o. offsetLeft
} While (op. contains (o ))
Return x
}
Function $ y (obj, op ){
Var o, y = 0
Op = op | document. body
Do {
O = null? $ (Obj): o. parentNode
If (op = o)
Break
If (o. tagName = "TR ")
Continue
Y + = o. offsetTop-o.scrollTop
} While (op. contains (o ))
Return y
}
Function getPngBg (url ){
Return document. all & \. png/I. test (url )? "Filter: progid: dximagetransform. microsoft. alphaimageloader (src =" + url + ", sizingMethod = scale)": "background: url (" + url + ")"
}
Function setHtm (op, str ){
Op = $ (op)
If (op. tagName = "TABLE "){
If (op. tBodies. length = 0)
Op. appendChild (document. createElement ("tbody "))
Op. replaceChild (document. createElement ("tbody"), op. tBodies [0])
}
Else
Op. innerHTML = ""
InsHtm (op, str)
}
Function insHtm (op, str, oRefer ){
Var bx = document. createElement ("div"), ol, I
Op = $ (op)
If (op. tagName = "TABLE "){
Bx. innerHTML = "<table>" + str + "</table>"
Ol = bx. childNodes [0]. tBodies [0]. rows
If (op. tBodies. length = 0)
Op. appendChild (document. createElement ("tbody "))
While (ol. length> 0 ){
Op. tBodies [0]. insertBefore (ol [0], oRefer = null? Null: oRefer)
}
}
Else {
Op. insertBefore (bx, oRefer = null? Null: oRefer)
Bx. outerHTML = str
}
BtBinding (op)
FmBinding (op)
}
Function btBinding (op ){
Var ol, I, a, bg
Ol = (op | document. body). getElementsByTagName ("SPAN ")
For (I = 0; I <ol. length; I ++ ){
If (ol [I]. getAttribute ("type ")! = "Button" | ol [I]. getAttribute ("bg") = null)
Continue
Bg = ol [I]. getAttribute ("bg ")
Ol [I]. removeAttribute ("bg ")
A = ol [I]. getAttribute ("pos"). split (",")
Ol[ I ].style.css Text = "position: absolute; overflow: hidden; left:" + a [0] + "; top:" + a [1] + "; width: "+ a [2] +"; height: "+ a [3]
Ol [I]. innerHTML = " <button style = position: absolute; left:-9000; top: 0> </button>"
Ol [I]. onmouseover = function () {this. scrollTop = this. offsetHeight}
Ol [I]. onmouseout = function () {this. scrollTop = 0}
Ol [I]. onmousedown = function () {this. scrollTop = this. offsetHeight * 2}
Ol [I]. onmouseup = function () {this. scrollTop = this. offsetHeight}
}
}
Function fmBinding (op ){
Var ol, I, sResult, foo
Ol = (op | document. body). getElementsByTagName ("FORM ")
For (I = 0; I <ol. length; I ++ ){
If (ol [I]. onsubmit! = Null)
Continue
InsHtm (ol [I], "<input name = btSubmit type = submit style = visibility: hidden>", ol [I]. firstChild)
Ol [I]. onkeydown = function (e ){
E = e | event
If (e. keyCode = 13)
Return false
}
Ol [I]. onsubmit = function (e ){
Var fm = this
If (! FmCheck (fm ))
Return false
SResult = 1
Try {
Foo = fm. getAttribute ("onbeforeload ")
If (typeof (foo) = "function ")
SResult = foo ()
Else if (typeof (foo) = "string ")
Eval (foo. replace (/return/, "sResult = "))
} Catch (e) {alert (e. description )}
If (sResult = false)
Return false
If (fm. method = "post "){
Fm.tar get = "wForm"
$ Sys. fmWinType = fm
Return true
}
LoadXml (fmv (fm), function (xml ){
Var foo = fm. getAttribute ("onload ")
If (typeof (foo) = "function ")
Foo (xml)
Else if (typeof (foo) = "string ")
Eval (foo)
})
Return false
}
}
}
Function fmWinOnLoad (win ){
Var xml, str, foo, error
If (document. all ){
Str=win.content{doc ument. body. innerText. replace (/\ n [\ s] * \-/g, "\ n ")
If (str = "")
Return
If (! /\ <[^ \>] +/. Test (str )){
Alert (str)
Return
}
Str = str. slice (1)
Xml = createXml (str)
}
Else {
If(win.content+doc ument + ""). indexOf ("XML") =-1)
Return
Xml=win.content##document.doc umentElement
}
Error = Newcastle (xml, "error ")
If (error! = Null)
Return alert (error)
Foo = $ sys. fmWinType. onload
If (typeof (foo) = "function ")
Foo (xml)
Else if (typeof (foo) = "string ")
Eval (foo)
}
Function fmv (fm ){
Var I, f, v, l
L = fm. action
For (I = 0; I <fm. length; I ++ ){
If (! "INPUT, TEXTAREA, SELECT". inc (fm [I]. tagName) | "submit, button". inc (fm [I]. type ))
Continue
V = fm [I]. value. trim ()
F = fm [I]. getAttribute ("postName") | fm [I]. name
If (f = "" | (fm [I]. type = "radio "&&! Fm [I]. checked) | fm [I]. readOnly = true)
Continue
If (fm [I]. type = "checkbox ")
V = fm [I]. checked? V. replace (/^ on $/g, 1): 0
L + = "&" + f + "=" + escape (v)
}
If (l. indexOf ("? ") =-1)
L = l. replace ("&","? ")
Return l
}
Function createXml (str ){
If (isIE ){
Var xml = new ActiveXObject ("Microsoft. XMLDOM ")
Xml. loadXML (str)
Xml. setProperty ("SelectionLanguage", "XPath ")
}
Else
Var xml = new DOMParser (). parseFromString (str, "text/xml ")
Return xml.doc umentElement
}
Function getXmlNode (node, expr, isAll ){
Var ol
If (isIE)
Ol = node. selectNodes (expr)
Else {
Var xpe = new XPathEvaluator (), nsr, res, ol = [], r
Nsr = xpe. createNSResolver (node. ownerDocument = null? Node.doc umentElement: node.ownerDocument.doc umentElement)
Res = xpe. evaluate (expr, node, nsr, 0, null)
While (r = res. iterateNext ()){
R. text = r. textContent
Ol. push (r)
}
}
Return isAll? Ol: ol [0]
}
Function Newcastle (node, expr, def ){
Var ol, s, $0, r
If (expr. indexOf ("@") = 0)
Return node. getAttribute (expr. slice (1) | def
Ol = getXmlNode (node, unescape (expr. slice (0 ,"? ")))
If (ol = null)
Return
If (ol. length = 0)
Return def
R = $0 = ol. length = 0? Def: unescape (ol. text)
Return r
}
Function loadXml (url, foo ){
Var xh, method, ondataok
Xh = isIE? New ActiveXObject ("Microsoft. XMLHTTP"): new XMLHttpRequest ()
Method = url. indexOf (". xml ")? "GET": "POST"
Xh. open (method, url, true)
Xh. setRequestHeader ("Content-Type", "application/x-www-form-urlencoded ")
Xh. send (method = "POST "? Url. slice ("? "): Null)
Ondataok = function (){
Var xml = xh. responseXML, error
If (xml! = Null)
Xmlbeanxh.responsexml.doc umentElement
If (xml = null ){
Window. clipboardData. setData ("text", $ sys. path + url)
Alert ("An error occurred while loading xml data! ")
Return
}
Error = Newcastle (xml, "error ")
If (error! = Null ){
Alert (error)
Return
}
Foo (xml)
}
If (xh. readyState = 4)
Ondataok ()
Xh. onreadystatechange = function (){
If (xh. readyState = 4)
Ondataok ()
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.