1

First question, is it even possible to write a URI (presumably http://) that will make a browser display some plaintext content, where the content is hardcoded into the URI itself (aka not served by a web server)?

My goal is to create a QR code that, when scanned, will display pre-encoded text content, regardless of device, OS, or internet connectivity. The simplest way I can imagine doing this is for the QR code to encode a URI that is opened by web browsers, since most devices with QR-scanning capabilities will also be capable of opening said link in a browser.

This is the tricky part: I would like the browser to open a plaintext page (which I believe is the same as the text/plain MIME type) without having to make a web request to a remote server. I would like the text content of the page to be hardcoded into the URI itself. I do not want to rely on JavaScript to display the text content. The goal is that this QR code (or the hyperlink encoded therein) could be opened on any modern device and produce a webpage displaying text, with no specific software required besides a web browser.

8
  • A hyperlink is only a shortcut, it MUST point to something. Browsers are generally specific-purpose tools, and you're asking whether it is possible not to subvert or adjust the purpose, but to have a different purpose altogether. I would guess this is entirely impossible, and certainly not widely compatible even if you can get a single browser client on one device to do this. It isn't going to be a support function on a broad collection of browsers on various devices. Commented May 23 at 23:56
  • @music2myear That's not a very accurate definition of a hyperlink, and doesn't reflect a particularly useful or accurate perspective on the question. A hyperlink points to a URI such as http:, https:, ftp:, webcal:, mailto:, and javascript:, to name a few that are commonly opened by web browsers by default. I know for a fact I could perform my task with a single javascript: link, but most browsers have restrictions that will only run JS in the form of bookmarklets, if at all, so that wouldn't be a broadly-compatible implementation.
    – ETL
    Commented May 24 at 0:33
  • Btw, if you're going to vote to close an issue due to being off-topic, you could at least share why you think so and suggest improvements. I posted this question here and not on SO because, in my view at least, it's about using existing software (URIs, browsers), not programming new software or using a CLI.
    – ETL
    Commented May 24 at 0:38
  • 1
    not possible. a querystring is meaningless without somthing to parse it, and that something is either client (javascript) or server side processing. a request is always required to load the contents at a URI, though the request does not need to be to a Remote server specifically. you can open a text file on your harddisk with a file:/// uri. all that said though, you are seeking some kind of processing in order to write querystring info to a page, so the whole question is moot. Commented May 24 at 3:54
  • also I should probably point out, that what you are trying to do will be considered a reflective cross-site scripting exploit, because if the text contained javascript it would likely execute in the client browser. Commented May 25 at 0:50

0

You must log in to answer this question.

Browse other questions tagged .