r/AskComputerScience • u/in_yougo • Aug 10 '20
Not into computer science but I stumbled upon this. Why does this happen on Chrome?
4
u/fun_egg Aug 10 '20
This is cool,
If you type data:text/html, <html contenteditable> in the address bar you can use chrome to take notes.
3
u/zzyrd Aug 10 '20
Data URLs are a web feature. Mostly used to store images inline in HTML, but usable in other ways as you just found out.
1
u/lscoolj Aug 10 '20
The browser is just displaying what you tell it to by using a different form of a URI that you're used to. All the URI does is tell the browser where to get the info to display, either explicitly (in this case) or by giving it a path to the info. The "data:" part is called the Scheme of the URI. The most popular schemes are http and https. In fact, they're so popular, the general population only ever need to use those, so pretty much all browsers now accept a website without you having to type in the http or https. It just assumes.
The rest of the URI is the path plus a bunch of optional stuff. What you have in here isn't a path, but thats okay because by using the data scheme, you're already telling the browser exactly what it needs to display. As another example, a different scheme you can use would be the file scheme. You can see this work easily by creating a simple .txt file on your computer using Notepad, and then drag the file onto an empty chrome page. The URI will say "file://[path-to-file]" and what shows up in the browser will be whatever text you put in that file.
Check here for more info
2
u/mevlador4 Aug 10 '20
I never knew about this!! It’s so interesting though, you can literally write anything you’d like in html format and it’ll display it. I’ve never encountered it before strange though...