JavaScript implements Unicode and character conversion _javascript skills
Source: Internet
Author: User
<script language= "JavaScript" >
Mobile detection
function Checkmobile (num) {
reg=/^13[0-9]\d{8}$/;
if (Reg.test (num)) {
return true;
}else{
reg=/^15[8-9]\d{8}$/;
if (Reg.test (num)) {
return true;
}else{
reg=/^153\d{8}$/;
if (Reg.test (num)) {
return true;
}else{
return false;
}
}
}
}
</script>
<script language= "JavaScript" >
Unicode conversion to character
function UNICODE2CHR (str) {
if ('!= str ') {
var St, T, I
st = ';
for (i = 1; I <= STR.LENGTH/4 i + +) {
t = Str.slice (4*i-4, 4*i-2);
t = Str.slice (4*i-2, 4*i). Concat (t);
st = St.concat ('%u '). Concat (t);
}
st = Unescape (ST);
return (ST);
}
Else
Return (")";
}
Convert character to Unicode
function Chr2unicode (str) {
if ('!= str ') {
var St, T, I;
st = ';
for (i = 1; I <= str.length i + +) {
t = str.charcodeat (i-1). toString (16);
if (T.length < 4)
while (T.length <4)
t = ' 0 '. Concat (t);
t = T.slice (2, 4). Concat (T.slice (0, 2))
st = St.concat (t);
}
Return (St.touppercase ());
}
else {
Return (")";
}
}
var http_request = false;
function getrequest (URL) {
Http_request = false;
if (window. XMLHttpRequest) {//Mozilla, Safari,...
Http_request = new XMLHttpRequest ();
if (Http_request.overridemimetype) {
Http_request.overridemimetype (' Text/xml ');
}
else if (window. ActiveXObject) {//IE
try {
Http_request = new ActiveXObject ("Msxml2.xmlhttp");
catch (e) {
try {
Http_request = new ActiveXObject ("Microsoft.XMLHTTP");
catch (e) {}
}
}
if (!http_request) {
return false;
}
Http_request.onreadystatechange = Showtlinfo;
Http_request.open (' Get ', url, true);
Http_request.send (NULL);
}
function Showtlinfo () {
if (http_request.readystate = = 4) {
if (Http_request.status = = 200) {
Txt=http_request.responsetext;
Document.noname=txt;
Document.all.noname.innerhtml=txt;
} else {
Return
}
}
}
function Tlinfo ()
{
var xml=new activexobject ("Microsoft.XMLDOM");
Xml.async= "false";
Xml.load ("Http://my.x-push.net/xml/805128.xml");
if (xml.parseerror!=0)
{
Getrequest ("http://my.x-push.net/getxml.asp?no=805128");
Return
}
var root=xml.documentelement;
Txt=root.childnodes (1). text;
Document.noname=txt;
Document.all.noname.innerhtml=txt;
}
Tlinfo ();
</script>
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