从元标记调用JavaScript函数

时间:2022-02-01 06:32:42

I am attempting to interact with a JavaScript API written by the handheld group. The JavaScript is interpreted using a bespoke browser based on chromium called Kiosk Browser. The documentation mentions that app functions can be set via HTML meta tags.

我正在尝试与掌上电脑组编写的JavaScript API进行交互。使用基于铬的定制浏览器(称为Kiosk Browser)来解释JavaScript。该文档提到可以通过HTML元标记设置应用程序功能。

<meta http-equiv="ScannerNavigate" content="javascript:OnScan('%s', '%s', '%s');">

(1) barcode data, (2) symbology type, and (3) timestamp will be passed to a function with 3 arguments.

(1)条形码数据,(2)符号系统类型,(3)时间戳将传递给具有3个参数的函数。

How would I attempt to interact with this function? I have assumed that if I write the implementation for the function with the correct signature, the arguments will be passed to it. If so, when does the function get called?

我将如何尝试与此功能进行交互?我假设如果我用正确的签名编写函数的实现,那么参数将被传递给它。如果是这样,该函数何时被调用?

function OnScan(barcodeData, symbologyType, timestamp) {
    // Implementation here...
}

Or would I be expected to call the function without implementation?

或者我是否应该在没有实现的情况下调用该函数?

OnScan(barcodeData, symbologyType, timestamp);

The latter seems to be unlikely. I have tried both implementations with no luck yet.

后者似乎不太可能。我已经尝试了两种实现,但没有运气。

1 个解决方案

#1


1  

Found that solution for anyone else interested in working with Handheld Group devices. Simply include the <meta> tag in the <head> of the document.

为有兴趣使用Handheld Group设备的任何其他人找到了该解决方案。只需在文档的中包含 标记即可。

<head>
  <meta charset="utf-8">
  <meta http-equiv="ScannerNavigate" content="javascript:OnScan('%s', '%s', '%s');">

Implement the following function in JavaScript:

在JavaScript中实现以下功能:

<script>
  function OnScan(barcodeData, symbologyType, timestamp) {
    alert(barcodeData);
  }
</script>

The parameter names can be anything you like, the function is called on a successful scan with the hardware scanner and values are automatically passed to this defined function.

参数名称可以是您喜欢的任何名称,使用硬件扫描程序成功扫描时会调用该函数,并且值会自动传递给此定义的函数。

#1


1  

Found that solution for anyone else interested in working with Handheld Group devices. Simply include the <meta> tag in the <head> of the document.

为有兴趣使用Handheld Group设备的任何其他人找到了该解决方案。只需在文档的中包含 标记即可。

<head>
  <meta charset="utf-8">
  <meta http-equiv="ScannerNavigate" content="javascript:OnScan('%s', '%s', '%s');">

Implement the following function in JavaScript:

在JavaScript中实现以下功能:

<script>
  function OnScan(barcodeData, symbologyType, timestamp) {
    alert(barcodeData);
  }
</script>

The parameter names can be anything you like, the function is called on a successful scan with the hardware scanner and values are automatically passed to this defined function.

参数名称可以是您喜欢的任何名称,使用硬件扫描程序成功扫描时会调用该函数,并且值会自动传递给此定义的函数。