Javascript in HTMLViewer

Hello everyone,

New to Xojo and I’m directly starting with a question about how to integrate Javascript into a web application.
So far, I’ve done a custom HTMLViewer in which I’ve put the method LoadPage.
Inside that method, my whole html & javascript is written.

However, when I had that customer HTMLViewer into the webpage and “Run” it, I can’t see anything.

Here is the Xojo view : https://prnt.sc/p6st79

The code I’m trying to run is a code that will get information from a cardreader.

here is the javascript:

[code]<script language="“javascript”">
function getIDData()
{
var strTemp;
var strTemp2;
var strTemp3;

    strTemp = document.BEIDApplet.getCardNumber() + ""&nbsp;"";
    document.getElementById('cardNumberField').innerHTML = strTemp;
    strTemp = document.BEIDApplet.getChipNumber() + ""&nbsp;"";
    document.getElementById('chipNumberField').innerHTML = strTemp;
    strTemp = document.BEIDApplet.getValidityDateBegin() + ""&nbsp;"";
    document.getElementById('valBeginField').innerHTML = strTemp;
    strTemp = document.BEIDApplet.getValidityDateEnd() + ""&nbsp;"";
    document.getElementById('valEndField').innerHTML = strTemp;
    strTemp = document.BEIDApplet.getIssMunicipality() + ""&nbsp;"";
    document.getElementById('issMunicField').innerHTML = strTemp;
    strTemp = document.BEIDApplet.getNationalNumber() + ""&nbsp;"";
    document.getElementById('natNumberField').innerHTML = strTemp;
    strTemp = document.BEIDApplet.getName() + ""&nbsp;"";
    document.getElementById('nameField').innerHTML = strTemp;
    strTemp = document.BEIDApplet.getFirstName1();
    strTemp2 = document.BEIDApplet.getFirstName2();
    strTemp3 = document.BEIDApplet.getFirstName3();
    document.getElementById('firstNamesField').innerHTML = strTemp + "" "" + strTemp2 + "" "" + strTemp3 + ""&nbsp;"";
    strTemp = document.BEIDApplet.getNationality() + ""&nbsp;"";
    document.getElementById('natField').innerHTML = strTemp;
    strTemp = document.BEIDApplet.getBirthLocation() + ""&nbsp;"";
    document.getElementById('birthLocField').innerHTML = strTemp;
    strTemp = document.BEIDApplet.getBirthDate() + ""&nbsp;"";
    document.getElementById('birthDateField').innerHTML = strTemp;
    strTemp = document.BEIDApplet.getSex() + ""&nbsp;"";
    document.getElementById('sexField').innerHTML = strTemp;
    document.BEIDApplet.getNobleCondition();
    document.BEIDApplet.getWhiteCane();
    document.BEIDApplet.getYellowCane();
    document.BEIDApplet.getExtendedMinority();
}

function getAddressData()
{
  var strTemp;
    var strTemp2;
    var strTemp3;
    strTemp = document.BEIDApplet.getStreet();
    strTemp2 = document.BEIDApplet.getStreetNumber();
    strTemp3 = document.BEIDApplet.getBoxNumber();
    document.getElementById('streetField').innerHTML = strTemp + "" "" + strTemp2 + "" "" + strTemp3 + ""&nbsp;"";
    strTemp = document.BEIDApplet.getZip();
    strTemp2 = document.BEIDApplet.getMunicipality();
    document.getElementById('municField').innerHTML = strTemp + "" "" + strTemp2 + ""&nbsp;"";
    strTemp = document.BEIDApplet.getCountry();
    if(strTemp == """" && strTemp2 != """")
    {
      strTemp = ""be"";
    }
    document.getElementById('countryField').innerHTML = strTemp + ""&nbsp;"";
}
function EmptyScreen()
{
    var strTemp = ""&nbsp;"";
    document.getElementById('cardNumberField').innerHTML = strTemp;
    document.getElementById('chipNumberField').innerHTML = strTemp;
    document.getElementById('valBeginField').innerHTML = strTemp;
    document.getElementById('valEndField').innerHTML = strTemp;
    document.getElementById('issMunicField').innerHTML = strTemp;
    document.getElementById('natNumberField').innerHTML = strTemp;
    document.getElementById('nameField').innerHTML = strTemp;
    document.getElementById('firstNamesField').innerHTML = strTemp;
    document.getElementById('natField').innerHTML = strTemp;
    document.getElementById('birthLocField').innerHTML = strTemp;
    document.getElementById('birthDateField').innerHTML = strTemp;
    document.getElementById('sexField').innerHTML = strTemp;
    document.getElementById('streetField').innerHTML = strTemp;
    document.getElementById('municField').innerHTML = strTemp;
    document.getElementById('countryField').innerHTML = strTemp;
    document.getElementById('StatusField').innerHTML = strTemp;
}

function ReadCard()
{
  var retval;
  EmptyScreen();
  document.getElementById('StatusField').innerHTML = ""Reading Card, please wait..."";
  retval = document.BEIDApplet.InitLib(null);
  if(retval == 0)
  {
    document.getElementById('StatusField').innerHTML = ""Reading Identity, please wait..."";
    getIDData();
    document.getElementById('StatusField').innerHTML = ""Reading Address, please wait..."";
    getAddressData();
    document.getElementById('StatusField').innerHTML = ""Reading Picture, please wait..."";
    document.BEIDApplet.GetPicture();
  document.BEIDApplet.ExitLib();
    document.getElementById('StatusField').innerHTML = ""Done"";
  }
else
  {
    document.getElementById('StatusField').innerHTML = ""Error Reading Card"";
  }
}

[/code]

And I have a button that will launch the code when pressed:

<td> <input type=""button"" name=""IDButton"" onclick=""javascript:ReadCard()"" value=""Read Card ""title=""Read Card""/> </td>

Can you give me a hint about what I should be doing in order to make it work?

Regards,

Charley

You can’t execute javascript on a HTMLViewer in Web. It’s a browser security thing, there is nothing you can do to work around this. What are you trying to do? Perhaps there’s a better way to approach it.

Hello Tim!
Thank you for your quick answer.

I’m trying to get data from a card reader in fill in directly mutliple fields to ease to creation of new clients (via their id card).
It’s a Belgian thing. I’ve been following the user guide and it seemed it was the option to do so (https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/eid-applet/eid-applet-dev-guide-1.1.3.pdf)

Hello,
Anyone can help on how I can integrate javascript to trigger actions when a button is clicked?

Regards,

Charley

You mean

  1. a button inside the HTML ?
  2. a button in the Xojo project ?

I took a bit more time to read all the messages.

First, please post Xojo Web questions in the Web channel. Your question also should read "Javascript in WebHTMLViewer "

The link you posted is for an applet generator, where javascript is fed to the browser from the URL line.

Once again, as already stated by Tim Parnell, you cannot access the WebHTML content when displaying another domain. Technically, WebHTMLViewer is an iFrame.