tools:javascript
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
tools:javascript [2025/09/30 22:44] – external edit 127.0.0.1 | tools:javascript [2025/10/12 10:51] (current) – Humphrey Boa-Gart | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | {{wst> | + | #redirect tools: |
- | + | ||
- | ====== JavaScript ====== | + | |
- | + | ||
- | JavaScript is a scripting language developed by Brendan Eich in 1995. | + | |
- | + | ||
- | ===== Adding text ===== | + | |
- | + | ||
- | One of the most basic commands in JavaScript is the document.write ("" | + | |
- | + | ||
- | <script LANGUAGE=" | + | |
- | document.write ("I like dongs" | + | |
- | </ | + | |
- | + | ||
- | ===== Adding comments ===== | + | |
- | + | ||
- | Another basic JavaScript command is the // command. Whatever is written after the two slashes will serve as a note or reminder, and will not show up in your document. | + | |
- | + | ||
- | <script LANGUAGE=" | + | |
- | // Do you like dongs?; | + | |
- | document.write ("I like dongs" | + | |
- | </ | + | |
- | + | ||
- | ===== Defining variables ===== | + | |
- | + | ||
- | Defining variables can be done by adding var followed by the variable name, the =, and then the value. If the value is something other than a number, you must surround it with quotation marks (example: var name=" | + | |
- | + | ||
- | <script LANGUAGE=" | + | |
- | // Do you like dongs?; | + | |
- | var x=2; | + | |
- | document.write ("I like dongs with x balls" | + | |
- | </ | + | |
- | + | ||
- | ==== Using specific phrases as variables ==== | + | |
- | + | ||
- | <script LANGUAGE=" | + | |
- | msg1=" | + | |
- | msg2=" | + | |
- | msg3=" | + | |
- | msg4=msg1+" | + | |
- | document.write (msg4); | + | |
- | document.write (msg3); | + | |
- | </ | + | |
- | + | ||
- | ===== Inserting special characters ===== | + | |
- | + | ||
- | In order to insert special characters, such as quotation marks, symbols, ampersands, apostrophes, | + | |
- | + | ||
- | <script LANGUAGE=" | + | |
- | document.write ("I liked Rick Astley' | + | |
- | </ | + | |
- | + | ||
- | ===== If...else ===== | + | |
- | + | ||
- | The if...else command can be useful in the case that under certain conditions, one thing will be true, but otherwise, another will be true. | + | |
- | + | ||
- | <script LANGUAGE=" | + | |
- | // Do you like dongs?; | + | |
- | var d=new Date(); | + | |
- | var time=d.getHours(); | + | |
- | if (time< | + | |
- | { | + | |
- | document.write ("I like dongs" | + | |
- | } | + | |
- | else | + | |
- | { | + | |
- | document.write ("I liek Mudkips" | + | |
- | } | + | |
- | </ | + | |
- | + | ||
- | ===== Popups ===== | + | |
- | + | ||
- | With a popup box, the alert ("" | + | |
- | + | ||
- | < | + | |
- | <script LANGUAGE=" | + | |
- | function show_alert() | + | |
- | { | + | |
- | alert(" | + | |
- | } | + | |
- | </ | + | |
- | </ | + | |
- | < | + | |
- | <input type=" | + | |
- | </ | + | |
- | + | ||
- | ===== Links ===== | + | |
- | + | ||
- | [[http:// | + | |
- | + | ||
- | [[http:// | + | |
- | + | ||
- | + | ||
- | {{tag> | + |
tools/javascript.txt · Last modified: by Humphrey Boa-Gart
Find this page online at: https://bestpoint.institute/tools/javascript
Find this page online at: https://bestpoint.institute/tools/javascript