I was under the impression that I only need to specify the "protocol" when using JavaScript in URL attributes, such as in hrefs. Is this the only "useful" context for javascript:
?
Sensible:
<a href="javascript:alert('Hello')">World!</a>
Silly:
<form onsubmit="javascript:alert('oops!')">
Is this right? Or is there some obscure bug/use case I need to be aware of?
The iterable protocol allows JavaScript objects to define or customize their iteration behavior, such as what values are looped over in a for...of construct. Some built-in types are built-in iterables with a default iteration behavior, such as Array or Map , while other types (such as Object ) are not.
Another way that JavaScript code can be included on the client side is in a URL following the javascript: pseudo-protocol specifier. This special protocol type specifies that the body of the URL is arbitrary JavaScript code to be interpreted by the JavaScript interpreter.
Window Location Port port property returns the number of the internet host port (of the current page).
pseudoprotocol (plural pseudoprotocols) (computing) Something that can be accessed in the manner of a protocol but is not in fact a protocol. quotations ▼
The javascript:
pseudo-protocol on event handlers will be only ignored, you don't need it, the JavaScript engine will interpret javascript:
as a Label Statement.
A label simply provides an identifier to a statement, and lets you refer to it elsewhere in your program.
IMHO, this pseudo-protocol is only useful for bookmarklets...
Recommended article:
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