Yesterday I posted a question about QR codes here on r/webdev, here is the link if you are interested.

Let me explain my idea first so you guys can have a clear understanding of what I want to achieve. There’s a small Coffe Shop that posted their menu as a PDF on a webpage, and they have a big QR code on the front of the shop that people can scan and it redirects them to the .pdf file. This is all fine and cool.

The problem is, since we are in a developing country, nearly 95% of the people outside do not have an internet connection on their mobile phones, nor WiFi / 3G.

What I am trying to do is to have a data: URL Scheme, containing the whole menu as a webpage along with SVG, CSS and the markup encoded in base64 and embeded into the QR code.

I did experiment with a basic webpage and a basic data: URL.

data:text/html;base64,PCFET0NUWVBFIGh0bWw+DQo8aHRtbD4NCiAgICA8aGVhZD4NCiAgICAgICAgPHRpdGxlPlFSIENvZGUgU2Nhbm5lZDwvdGl0bGU+DQogICAgICAgIDxzdHlsZT4NCiAgICAgICAgICAgICogew0KICAgICAgICAgICAgICAgIG1hcmdpbjogMDsNCiAgICAgICAgICAgICAgICBwYWRkaW5nOiAwOw0KICAgICAgICAgICAgfQ0KDQogICAgICAgICAgICBoMSB7DQogICAgICAgICAgICAgICAgY29sb3I6IGJsdWU7DQogICAgICAgICAgICAgICAgYmFja2dyb3VuZC1jb2xvcjogYnVybHl3b29kOw0KICAgICAgICAgICAgICAgIHRleHQtYWxpZ246IGNlbnRlcjsNCiAgICAgICAgICAgIH0NCiAgICAgICAgPC9zdHlsZT4NCiAgICA8L2hlYWQ+DQogICAgPGJvZHk+DQogICAgICAgIDxoMT4NCiAgICAgICAgICAgIEhlbGxvIFdvcmxkDQogICAgICAgIDwvaDE+DQogICAgPC9ib2R5Pg0KPC9odG1sPg==

When the above is copied and pasted into the url bar of any browser, the brwoser itself is rendering everything quite beautifully to be honest, however, it works when copied and pasted or written into the url bar manually.

Using an online QR Code generator, I tried pasting in the above code as a URL, the generator did provide me a QR code, here it is:

Post image

Whenever I am scanning the QR Code, the scanner is correctly figuring out the code of the data: so our first step worked, however when I try to open it in a browser (Which I can after the scan is complete, selecting which app I want the link to open in) what happens is the browser is either displaying an error message or simply doing a Google Search on the scanned code. The reason as stated in one of the discussion in my last post is probably a security measure by the browsers.

My question is, are there any workarounds on the browser security issue that makes them not handle the scanned link at all?

Other then that, do you have any other approaches to the whole idea?

Sorry for the long post, and your help would be really reaaally appreciated! Thanks!



Source link

Write A Comment