Sunday 5 June 2011

3 Javascript Masters: The Creator, The Humble Writer and The Show Off

Wham! Another weekend over, but wait, it's not all bad news! This week has been one of the most productive in the DMD Studio.

I have been concentrating on the 3 main components of Javascript in order to make designs more dynamic and playful...

- Variables
- Conditionals
- Loops

Although it's not the easiest language to get your head around, it is fun, so here are 3 simpler snippets of coding you can start with in order to set a firm foundation toward mastering its wondrous delights.

The Creator - Script Tags:
Javascript, much like HTML, needs tags to tell a browser what it is. The tags used to do this are script tags which look like this:

<script type="text/javascript">
     ***content goes here***
</script>

The Humble Writer - Document Write:
In order to write to the page you must use the prefix document.write. This will sit inside the scripting tags, like this (don't forget the cheeky semi-colon at the end of the statement):

<script type="text/javascript">

     document.write("hello world");
</script>

The Show Off - Alert:

Alerts prompt the browser to display a small box with a message and an action. You may have already seen these when you are exiting out of an online document without saving. You can create one very simply, using this code as a guide:

<script type="text/javascript">

     alert("hello world");
</script>

That's all for now folks. I'm be in touch with more complex levels of scripting soon.

Good luck and happy scripting!
DM x
__________________________
P.S. Before I go, a big thank you to all of those who have sent in your work to be featured on the DMD blog walls - keep checking back for when it goes live at the end of July 2011.

No comments:

Post a Comment