Answer the question
In order to leave comments, you need to log in
Why is it possible to run javascript code in the address bar of a browser?
Interested in the mechanism of the browser. Please, in simple words.
Answer the question
In order to leave comments, you need to log in
Because javascript is executed on the client side. And the address bar of the browser can be used as a console.
Those. write http// site - it accesses the site using the http protocol. FTP://address - via ftp
Write javascript:commands - it executes them like a javascript console that runs in the browser on the client side.
More or less like this. Those. in the address bar you tell the browser what to do
And why not actually. By the way, it's kind of like in the latest versions of FF it seems like it's no longer possible to do this or they are just going to ...
In general, it happened historically, when only Netscape and IE were on the market. Then JS just appeared, W3C didn’t seem to standardize DOM events yet, and in general, some kind of trash was going on. Some browser developer made it possible to do this:
people liked it. Other developers have taken up the idea. To make it all work, we decided to execute the JS entered as a URL, with its own protocol and all that. This is a kind of heritage of ancient times. Although this is only one of the versions.
Now this practice is considered bad form, and a lot of lemings distribute their cookies left and right in this way, because they like to copy and paste everything that is not right.
Because there is a javascript protocol: and bookmarks. The content of the answer fit perfectly into the answer.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question