I stumbled upon something strange that I never really seen before:
javascript:a=a+10;
The line above seems to be correct and evaluates happily (at least in Firefox) just like if the javascript:
part never existed.
While I do understand the purpose of the old javascript:void(...)
style <a href=".."/>
used during the dark ages of DHTML, I just can't figure out any useful usage of this prefix in plain JavaScript code.
Does it have some special meaning?
JavaScript is a text-based programming language used both on the client-side and server-side that allows you to make web pages interactive. Where HTML and CSS are languages that give structure and style to web pages, JavaScript gives web pages interactive elements that engage a user.
JavaScript is a flexible and powerful programming language that is implemented consistently by various web browsers. Along with HTML and CSS, it's a core component of web technology. While HTML is responsible for structure and CSS is responsible for style, JavaScript provides interactivity to web pages in the browser.
$ is simply a valid JavaScript identifier. JavaScript allows upper and lower letters, numbers, and $ and _ . The $ was intended to be used for machine-generated variables (such as $0001 ). Prototype, jQuery, and most javascript libraries use the $ as the primary base object (or function).
The way JavaScript works is interesting. Inside a normal Web page you place some JavaScript code (See How Web Pages Work for details on Web pages). When the browser loads the page, the browser has a built-in interpreter that reads the JavaScript code it finds in the page and runs it.
The "javascript:
" is a label. It's supposed to be used to identify a loop so that you could then use "break javascript;
" to break out of it, but is being misused here. It's harmless, but probably not a good idea to add a label to a statement that isn't a loop.
It is syntactically valid (it is a label) but useless. It is cargo culting caused by people copy/pasting code without understanding it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With