LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Call Javascript in Web VI LabVIEW NXG

Hello all,

I would like to get the pressed key by using Javascript. 

I try this javascript code saved as key.js

Spoiler
(function () {
// Use strict prevents silent and common JavaScript errors.
'use strict';
var key = function(event)
{
var char = event.which || event.keyCode;
return char;
};
}());

In LabVIEW NXG, I add the JS Library Interface like this. 

d4nvjpl0ng4n_0-1592462019331.png

 

However, when I run the index.gviweb, I got this error

d4nvjpl0ng4n_1-1592462069131.png

I don't know what wrong I have done. Please help me. I am very new with Javascript.

 

Thank you in advance.

 

 

0 Kudos
Message 1 of 3
(2,727 Views)

Furthermore, how can we achieve the ID of control in Web VI?

For example, I would like to use this code. How can I replace the ("42") by the NI ID format like ni-control-id = '42'?

document.getElementById("42").innerHTML

 Thank you in advance

0 Kudos
Message 2 of 3
(2,679 Views)
0 Kudos
Message 3 of 3
(2,580 Views)