'store html on nfc tag

can NFC tags readers, especially on Android, open a webpage stored on the tag after being scanned?

I don't want to store a URL, I want to store a webpage in plain text and have that render after it is scanned. Is this supported?

<html><body>No signal? Bookmark this page!<img src="http://bit.ly/example"/>Test Image</img></body></html>

The above example is only 106 bytes, so can fit on most NFC tags, would this open in a webpage or can there be certain instructions to render it as a webpage?



Solution 1:[1]

Yes you can store a web page on an NFC tag - in fact you could store anything. That does not mean that it is a good idea. If you do not decide on the tags to be used, html is a bad idea. Rather store an URL and get the data online. Or store the data in a more compact format.

Solution 2:[2]

EDITED ADDITIONAL INFO:

The Android Developer site at this link:

https://developer.android.com/guide/topics/connectivity/nfc/nfc

contains a wealth of information which, upon reading, explains why this particular approach is challenging, but also inspires a while heap of other alternative ideas, methods, ways and means... I strongly recommend checking it out!!!

********** End Of Edit ************

ORIGINAL ANSWER:

I have experimented with the very same, and created a custom NDEF message of MIME type text/html, with a fully coded HTML document as text in the data field of said MIME type ( & all standard tags such as & & so on). I have not had any luck with having the page rendered in a browser window. Usually, on scanning the NFC chip, it just returns a new-tag response showing my MIME "text/html" prefix, and completely omits the display of even the associated HTML encoding!

It's very frustrating..

However - in going to try again, as I understand that a recent release of Chrome Browser has a flag for experimental NFC features that can be activated.

In the Chrome Browser, navigate to chrome://chrome-urls and choose the flags link (or just go straight to chrome://flags ), then in the search bar type NFC. When the two or so options are presented, change the flags from default to enabled.

Now, I know that this then allows websites to interact with data on NFC tags, and allows you to script the content fields as variables, etc etc etc, but I DON'T know if it will solve our "render MIME type text/html record as web page directly" problem.

I will test it out and let you know...

Solution 3:[3]

I had a similar thought to you and was investigating this idea. However android by default do not have an app that can recognize such tag by default... not even android chrome.

But what I did end up doing to explore this was to create an NFC tag project that can generate a tag with a mime record of text/html or text/html+gzip (FYI: text/html+gzip technically is not an officially registered mime record type, however I think it still keeps to the normal semantic of other mime record that combines a format + compression). It's located at https://github.com/mofosyne/js-ndef-html-tag to generate a tag.

As for viewing it, I've created an experimental android app where I have also placed an intent hook for both text/html or text/html+gzip so that any NFC tag with such content will automatically open up https://github.com/mofosyne/NFCMessageBoard and display the tag's html content.

However ideally you would push android to add native support for viewing html tags directly.

Until then, the official answer is no you cannot.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ThomasRS
Solution 2
Solution 3 Brian