Table of Contents
This article was imported from the 2011 Insurgency Wiki backup, and sits here in its original crude format. It is in dire need of modernization and cleanup.
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 (“”) command. Whatever you write between the first quotation mark and the second quotation mark is what will be written on the page.
<script LANGUAGE="JavaScript" type="text/javascript"> document.write ("I like dongs"); </script>
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=“JavaScript” type=“text/javascript”> Do you like dongs?;
document.write ("I like dongs"); </script>
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=“dongs”).
<script LANGUAGE="JavaScript" type="text/javascript"> // Do you like dongs?; var x=2; document.write ("I like dongs with x balls"); </script>
Using specific phrases as variables
<script LANGUAGE="JavaScript" type="text/javascript"> msg1="so i herd"; msg2="u liek mudkips"; msg3="I FUCKING LUUUURVE MUDKIPS"; msg4=msg1+" "+msg2; document.write (msg4); document.write (msg3); </script>
Inserting special characters
In order to insert special characters, such as quotation marks, symbols, ampersands, apostrophes, etc, they must be preceded by a backslash.
<script LANGUAGE="JavaScript" type="text/javascript"> document.write ("I liked Rick Astley's song \"Never Gonna Give You Up\" because it's awesome.") </script>
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="JavaScript" type="text/javascript"> // Do you like dongs?; var d=new Date(); var time=d.getHours(); if (time<6) { document.write ("I like dongs"); } else { document.write ("I liek Mudkips") } </script>
Popups
With a popup box, the alert (“”) will be the text inside of the box, and the value=“” underneath will serve as the button you must press in order to make the popup box appear.
<head> <script LANGUAGE="JavaScript" type="text/javascript"> function show_alert() { alert("Yes, I luuuuurve dongs"); } </script> </head> <body> <input type="button" onclick="show_alert()" value="Do you like dongs?" /> </body>
Links
Find this page online at: https://bestpoint.institute/tools/javascript