Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Bookmarklet
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Concept == Web browsers use [[Uniform Resource Identifier|URI]]s for the <code>href</code> attribute of the <syntaxhighlight lang="HTML" inline><a></syntaxhighlight> tag and for bookmarks. The URI scheme, such as <code>http</code> or <code>ftp</code>, and which generally specifies the [[Protocol (computing)|protocol]], determines the format of the rest of the string. Browsers also implement <code>javascript:</code> URIs that to a parser is just like any other URI. The browser recognizes the specified <code>''javascript''</code> scheme and treats the rest of the string as a JavaScript program which is then executed. The expression result, if any, is treated as the HTML [[source code]] for a new page displayed in place of the original. The executing script has access to the current page, which it may inspect and change. If the script returns an undefined type (rather than, for example, a string), the browser will not load a new page, with the result that the script simply runs against the current page content. This permits changes such as in-place font size and color changes without a page reload. An [[Immediately invoked function expression|immediately invoked function]] that returns no value or an expression preceded by the <code>void</code> operator will prevent the browser from attempting to parse the result of the evaluation as a snippet of HTML markup: <syntaxhighlight lang="javascript" line="1" start="1"> javascript:(function(){ //Statements returning a non-undefined type, e.g. assignments })(); </syntaxhighlight>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)