Hacker News new | past | comments | ask | show | jobs | submit login

Wow, I did not know that we could create tiny "serverless" pages like that.

I created this self referencing URL:

`data:text/html, <html><head><title>SO META</title></head><body><h1>This link's url is</h1><script>p = document.createElement("p");p.innerText = window.location.href;document.body.appendChild(p)</script></body></html>`

The sad part is that <a href>'s are actually blocked from using data:text/html URLs. So we can still create tiny games and apps that can be copy/pasted in the address bar, but we can't link to them.




Maybe that’s a feature, not a bug.

If we can put the data in an image file a user could drag a cart into their address bar to load up a game. So we can pass around carts like images.


You may not be able to <a> to them, but you can certainly issue redirects to them, and <a> to a URL that issues such a redirect.

You can also <a> to a URL that issues a redirect to a location given by a GET parameter, eliminating the need to stand up a site for every different idea you come up with.


That used to be possible [1], but it looks like redirection to a data url is blocked on current versions of Chrome and Firefox.

[1] http://indirection.modusponens.org/data:text/html,Hello,%20w...!


In chrome, what's blocked is page-initiated top-level navigations to data URLs (because of spoofing concerns). You can load them in iframes, and you can still do a browser-initiated navigation to them (i.e., type them into the omnibox). They can be used freely as subresources.

Http Redirection to data: urls has been blocked in chrome for at least half a decade. There's really no reason to allow that, a server can just as easily return the data as the response body.


how about using document.write to go to the new self contained page

<a onclick="document.write('<html>...</html>'">other game<\a>




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: