Generate a QR code image by using a string (which can be Chinese characters and transcode Chinese characters before generating the QR code image). If you want to include the QR code of log, you can add a small log in the middle of the generated QR code. The log image should not be too large, otherwise the content will not be scanned.
Copy codeThe Code is as follows:
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Title> </title>
<Script src = "js/jquery-1.8.3.js" type = "text/javascript"> </script>
<Script src = "js/qrcode. js" type = "text/javascript"> </script>
<Script src = "js/jquery. qrcode. js" type = "text/javascript"> </script>
<Script type = "text/javascript">
$ (Function (){
$ ("# Bt"). bind ("click", function (){
Text = $ ("# text"). val ();
$ ("# Div_div"). qrcode (utf16to8 (text ));
})
})
Function utf16to8 (str) {// Transcoding
Var out, I, len, c;
Out = "";
Len = str. length;
For (I = 0; I <len; I ++ ){
C = str. charCodeAt (I );
If (c> = 0x0001) & (c <= 0x007F )){
Out + = str. charAt (I );
} Else if (c> 0x07FF ){
Out + = String. fromCharCode (0xE0 | (c> 12) & 0x0F ));
Out + = String. fromCharCode (0x80 | (c> 6) & 0x3F ));
Out + = String. fromCharCode (0x80 | (c> 0) & 0x3F ));
} Else {
Out + = String. fromCharCode (0xC0 | (c> 6) & 0x1F ));
Out + = String. fromCharCode (0x80 | (c> 0) & 0x3F ));
}
}
Return out;
}
</Script>
</Head>
<Body>
<Input type = "text" id = "text"/>
<Input type = "button" value = "shengc" id = "bt"/>
<Div id = "div_div" style = "width: 400px; height: 400px; border: 1px solid #000;"> </div>
</Body>
</Html>
Three js packages are referenced here, one of which is the jquery package. The other two are the js packages used to draw the QR code.
Js package download http://download.csdn.net/detail/anxin591025/6254607