JavaScript basics
Some basic JavaScripts
<script type="text/javascript">
document.write("Hello World!")
</script>
<html>
<body>
<script type="text/javascript">
document.write("This is my first JavaScript!");
</script>
</body>
</html>
Send the client to a new location / URL
<script type="text/javascript">
window.location="http://www.zimplicit.se";
</script>
[/codefilter_code]
Write some text in the windows status bar
<script type="text/javascript">
window.status="Some text in the status bar!!";
</script>
Return the length of a string
<script type="text/javascript">
var txt="Hello World!";
document.write(txt.length);
</script>
Try Catch
<script type="text/javascript">
var txt="";
function message()
{
try
{
aXXXlert("Welcome guest!"); //Should generate error!
}
catch(err)
{
txt="There was an error on this page.\n\n";
txt+="Click OK to continue viewing this page,\n";
txt+="or Cancel to return to the home page.\n\n";
if(!confirm(txt))
{
document.location.href="http://www.zimplicit.se/";
}
}
}
</script>
Knowledge keywords: