Bonjour, j'ai trouvé un script que je comprends pas sur internet pour un navigateur enrichi.
Comment le passage de paramètres se fait-il à la fonction doScan() ?
Il met des %s partout , je ne comprend pas comment je peux passer des paramètres correctement.
Sachant que la doc du scannernavigate est présente ici :
When this tag is present, Symbol PocketBrowser will not process scanned data as keyboard messages, instead it will navigate Symbol PocketBrowser to the link or call the JavaScript function specified in the content parameter of the “ScannerNavigate” tag, after a successful decode
of a barcode. The data from the scan will be populated into the Querystring replacing ‘%s’ parameters with "data", "source", "type", "time" and "length" values in that order.
Parameters
HTTP-Equiv="ScannerNavigate"
Content=“URL to navigate to/JavaScript[Format]”
Remarks
This tag is page specific, and will only apply on the page that specifies it.
Any data stored in a form on the page will not be added to the Querystring.
You must ensure that there are no more than 5 occurrences of “%s” within the
contents field as this will result in unreliable results.
Example
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 <HTML> <HEAD> <META HTTP-Equiv="Scanner" content=Enabled"> <META HTTP-Equiv="ScannerNavigate" content=/scan.htm?Data=%s&Source=%s&Type=%s&Time=%s&Length=%s"> <!- or --> <META HTTP-Equiv="ScannerNavigate" content=Javascript:OnScan(%s,%s,%s,%s,%s);"> <TITLE>Symbol PocketBrowser</TITLE> </HEAD> <BODY> <P align="center"><IMG SRC="symbol.jpg"></P> </BODY> <SCRIPT> function OnScan(data, source, type, time, length) { alert(The barcode scanned was + data + \nThe symbology was + source + \nScanned at + time + \nWith a length of + length); } </SCRIPT> </HTML>
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45 <HTML> <head> <meta http-equiv="scanner" content="Enabled"> <meta http-equiv="scannernavigate" content="Javascript:doScan('%s', '%s', %s, '%s', %s);"> <title>SPB Scanner Sample</title> <script src="SPBScan_ScanData.js"></script> <link HREF="SPB_Scanner_Sample.css" REL="stylesheet" TYPE="text/css"> </head> <body leftmargin="0" topmargin="0" rightmargin="0" bottommargin="0" width="238" bgcolor="#E6ECED" text="#000000" link="#000000" onload="doAfterLoad()"> <div style="text-align: center;"> <table border="0" cellpadding="0" cellspacing="0" width="238"> <tr> <td> <div class="titlecontainer"> SPB Scanner Sample </div> </td> </tr> <tr> <td> <div class="scanneddatamsg">Scan a barcode <br> <p> </div> <div id="content" class="scanneddatadiscription"> <img src="images/scannerimage.jpg" width="209" height="84"><br><br><br><br><br><br><br><br> </div> <div class="actionlisttcontainer"> <a style='text-decoration: none;' href="SPBScan_Symbology.htm">Codes</a>|<a style='text-decoration: none;' href="SPBScan_SelectParamDecoder.htm">Params</a>|<a style='text-decoration: none;' href="SPBScan_SelectLengthDecoder.htm">Length</a>|<a style='text-decoration: none;' href="../SPB_Sample_Menu.html">Back</a> </div> </td> </tr> </table> <table border="0" cellpadding="0" cellspacing="0" width="238"> <tr> <td align="center"> <div class="bottomcontainer"> Copyright © 2007 Motorola, Inc </div> </td> </tr> </table> </div> </BODY> </HTML>
SPBScan_ScanData.js
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 /************************************************************************************************* THIS FUNCTION DISPLAYS RECEIVED BARCODE DATA WITH ADDITIONAL DISCRIPTIVE LABLES ***********************************************************************************************/ function doScan(data, source, type, time, length) { content.innerHTML = 'Data: <br><textarea name="textarea" rows="4" cols="24" class="scanneddatatext">' + data + '</textarea><br><table border="0" width="100%" id="table1" class="scanneddatadiscription"> <tr> <td>Source </td><td>: '+source+'</td></tr><tr> <td>Time </td><td>: '+time+'</td></tr><tr><td>Length </td> <td>: '+length+'</td></tr><tr><td>Type </td><td>: '+type+'</td> </tr></table><br>'; } /************************************************************************************************* THIS FUNCTION CALLS DURING PAGE LOAD TIME ***********************************************************************************************/ function doAfterLoad() { setTimeout('doSetFocus();', 500); } /************************************************************************************************* THIS FUNCTION SETS THE FOCUS TO GIVEN ITEM ***********************************************************************************************/ function doSetFocus() { document.links[0].focus(); }
Partager