Baidu stellt Webmaster derzeit JS -Skripte zur Verfügung, um die Art des mobilen Terminals und automatisch zu beurteilen, was die Mehrheit der Webmaster und Webentwickler erheblich erleichtert. Die Verwendung seines JS -Skripts ist extrem einfach.
Die Codekopie lautet wie folgt:
<script src = "http://sineApp.baidu.com/static/webappservice/uaredirect.js" type = "text/javaScript"> </script>
<Script type = text/javaScript> uaredirect ("Mobile Site", "Website"); </script>
Der CORE CORE JS -Skript -Formatierungscode ist wie folgt:
Die Codekopie lautet wie folgt:
Funktion uaredirect (f) {
versuchen {
if (document.getElementById ("bdmark")! = null) {
Zurückkehren
}
var b = false;
if (Argumente [1]) {
var e = window.location.host;
var a = window.location.href;
if (issubdomain (Argumente [1], e) == 1) {
f = f + "/#m/" + a;
B = wahr
} anders {
if (issubdomain (Argumente [1], e) == 2) {
f = f + "/#m/" + a;
B = wahr
} anders {
f = a;
B = falsch
}
}
} anders {
B = wahr
}
if (b) {
var c = window.location.hash;
if (! c.match ("fromApp")) {
if ((navigator.useragent.match (/(iPhone | iPod | Android | iOS)/i)) {
Ort.Replace (f)
}
}
}
} catch (d) {}
}
Funktion issubdomain (c, d) {
this.getDomain = Funktion (f) {
var e = f.indexof (": //");
if (e> 0) {
var h = f.substr (e + 3)
} anders {
var h = f
}
var g = /^ www/./;
if (g.test (h)) {
H = H.Substr (4)
}
Rückkehr h
};
if (c == d) {
Rückkehr 1
} anders {
var c = this.getDomain (c);
var b = this.getDomain (d);
if (c == b) {
Rückkehr 1
} anders {
C = C.Replace (".", "//.");
var a = new regexp ("//." + c + "$");
if (b.match (a)) {
Rückkehr 2
} anders {
Rückkehr 0
}
}
}
};
Es wird empfohlen, dass Webmaster und Webentwickler die komprimierten JS -Skripte wie folgt verwenden
Die Codekopie lautet wie folgt:
Funktion uaredirect (f) {try {if (document.getElementById ("bdmark")! a = window.location.href; if (issubdomain (Argumente [1], e) == 1) {f = f+"/#m/"+a; b = true} else {iss Ubdomain (Argumente [1], e) == 2) {f = f+"/#m/"+a; b = true} else {f = a; b = false}}} else {b = true} if (b) {var c = window.location.hash; if (! c.match ("fromApp") {if ((navigator.useragent.match (/iPhone | iPod | Android | iOS)/i)) {location.replace (f)}}}}} {d) {}}} function (c, d) {th e = f.indexof (": //"); if (e> 0) {var h = f.substr (e+3)} else {var h = f} var g =/^www /./; if (g.test (h)) {H = H.Substr (4)} return H}; b = this.getDomain (d); if (c == b) {return 1} else {c = c.Replace (".", "//."); var a = new Regexp ("//."+ c+" $ "); if (b.match (a)) {return 2} {return 0}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}} {c = c.
PS: Hier empfiehlt der Editor mehrere JavaScript -Formatierungs-, Verschönerungs- und Komprimierungswerkzeuge. Ähnlich wie bei der oben genannten Baidu -Jump -Code -Komprimierung und -formatierung können Sie die folgenden Tools verwenden, um es zu implementieren:
C Sprachstil/HTML/CSS/JSON -Code -Formatierung und Verschönerungswerkzeuge:
http://tools.vevb.com/code/ccode_html_css_json
Online -Tools für JavaScript -Code Verschönerung und Formatierung:
http://tools.vevb.com/code/js
JavaScript Code Verschönerung/Komprimierung/Formatierung/Verschlüsselungstools:
http://tools.vevb.com/code/jscompress
JavaScript Online -Komprimierungstool:
http://tools.vevb.com/code/js_yasuo
JavaScript -Online -Formatierungs -Tool (basierend auf Beautify.js Plugin):
http://tools.vevb.com/code/js_beautify