K
K
Kevin2014-12-08 18:26:45
JavaScript
Kevin, 2014-12-08 18:26:45

Where can I find any information on the javascript and data protocols?

I often met similar parts of the code and the last time I saw it on Wikipedia:

A typical example would be a link <a href="javascript:DoSomething()">. Even if the forum allows external links, the javascript: and data: protocols should not be allowed .

So, I don’t really understand when these protocols are used and why they are needed at all, Google didn’t help (maybe I googled weakly, now I continue to do this).
Therefore, if someone has any information or links to articles, etc. on these protocols, can you tell me?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
R
Rishat Kadyrov, 2014-12-08
@Klanc

For example, you have a 20-byte image. You feel sorry for the server (since each image is a separate request), so you just insert it directly into the html. An increase in the html file by 20 bytes is imperceptible, and the absence of an extra request is nice. It's the same with scripts. That is, this is a pseudo-protocol that allows you not to go anywhere, but to take information about external resources directly from the HTML content.
But in practice it is rarely used, since there are more advanced techniques, and there are many shortcomings.

A
Alexander Aksentiev, 2014-12-08
@Sanasol

it's just calling a JS function by clicking on a link. I mean don't filter links starting with javascript: and data:

D
Dmitry Serzhenko, 2015-06-20
@Serzhenko

They are not protocols, but URI schemes . data is official, javascript is not.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question