Wechat scan function is very simple, there are two ways to open: 1. Top right +, and then click “Scan” 2. “Discover” -> “Scan”
It can sweep: two-dimensional code, small program code, bar code and other codes, because of the popularity of wechat, resulting in people scan code needs will immediately think of wechat. As if sweep code and wechat sweep code painting equal sign, have to admire the influence of wechat.
In daily life, we use it to scan the code to pay, scan the code to log in to a web page, or open a small program, or scan the code to display a paragraph of text and so on. The action after scanning code depends on the qr code that is scanned. If the content of the QR code is the URL, then wechat will automatically jump to such a url format, in addition to some special URLS (such as IP address, the blocked url, competitor’s address and so on). You want to scan the code after jumping to the specified url is impossible! Unless you can change the wechat program.
But things are not so absolute. Is there no other place to open the wechat scan function besides the two ways listed above? The answer is yes. Many of you have come across web forms that have a text input field followed by a scan icon. Click the scan icon will enable the scan function, and wechat scan looks exactly the same, aiming at the TWO-DIMENSIONAL code or bar code, drop the content of the two-dimensional code or bar code will appear in the web page. So said so much nonsense, “wechat scan two-dimensional code after how to jump to the designated website?” What the hell is going on? , the answer is only in their own webpage procedures, you must first have a little programming of basic knowledge reserves, if it is a code farmer better, technology is not much high, will copy and paste the kind of line, of course, can know a little HTML and JS is better.
<input type="text" id="sn">
<a href="https://www.996315.com/api/scan/">Scan</a>
<script type="text/javascript">
var qr=GetQueryString("qrresult");
if(qr) document.all.sn.value=qr;
function GetQueryString(name){
var reg = new RegExp("\b"+ name +"= (/ ^ & *)");
var r = location.href.match(reg);
if(r! =null) return decodeURIComponent(r[1]);
}
</script>
Copy the code
Save the above code in a.htm file, for example, saoma.htm, and upload it to your web site (either Intranet or exintranet server). Then visit it, click “Scan” inside to scan the QR code or bar code, you will see the scanned items displayed in the input box.
The above picture is a barcode of a Courier order
Note: The barcode content of the express bill should only be a number, but wechat will also display the barcode type on it. There are more than ten barcode types, for example, the express bill uses CODE_128. If you don’t want this content, you can use qr.split(“,”)[1] to separate it by comma and then go to array 2.
What if I want to jump to a specific url? The answer is to jump through the window.open method of JS code, for example, jump to Baidu after scanning.
<input type="text" id="sn">
<a href="https://www.996315.com/api/scan/">Scan</a>
<script type="text/javascript">
var qr=GetQueryString("qrresult");
if(qr) window.open("https://www.baidu.com");
function GetQueryString(name){
var reg = new RegExp("\b"+ name +"= (/ ^ & *)");
var r = location.href.match(reg);
if(r! =null) return decodeURIComponent(r[1]);
}
</script>
Copy the code
But what’s the point of just jumping? It has nothing to do with the QR code we scanned. To make sense of it, I decided to expand.
We often see the bar code on the express bill, right? Have you tried to search the tracking number in Baidu directly? No need to enter the express name, it can display the logistics information! Baidu search link structure is like this: www.baidu.com/s?wd= keyword, so we can modify it like this:
<input type="text" id="sn">
<a href="https://www.996315.com/api/scan/">Scan</a>
<script type="text/javascript">
var qr=GetQueryString("qrresult");
if(qr) window.open("https://www.baidu.com/s?wd=" + qr.split(",") [1]);
function GetQueryString(name){
var reg = new RegExp("\b"+ name +"= (/ ^ & *)");
var r = location.href.match(reg);
if(r! =null) return decodeURIComponent(r[1]);
}
</script>
Copy the code
Save as xx.htm file, upload to the server, access this address, and then click “scan” to casually scan a Courier order bar code to see, magic thing happened, it can actually query express logistics information!