Search code examples
javascriptgoogle-chromenfc

Uncaught ReferenceError: ChromeSamples is not defined at (index):24:1


When testing out Web NFC and following the script example given by GoogleChrome on Github I get error when trying to deploy my site on www.000webhost.com. How can I fix it?

Error:

Uncaught ReferenceError: ChromeSamples is not defined
at (index):24:1

The error is reffering to index.html (see full script on Github link) files following lines:

<script>
log = ChromeSamples.log;

if (!("NDEFReader" in window))
  ChromeSamples.setStatus("Web NFC is not available. Use Chrome on Android.");
</script>

Solution

  • Solution: Have to include the output_helper.html content into the following index.html line:

    {% include output_helper.html initial_output_content=initial_output_content %}
    

    Why? Because the repository in the link is using Jekyll (it's a templating engine for Ruby) and automatically fills this index.html line with output_helper.html contents. If you are not using Jekyll then you have to manually insert the linked contents.

    Here is a repository with NFC reader and writer working in Google chrome. Star the repository if it helped you!

    Thank you @Phil for providing this answer in the comments!