Fun with JavaScript
When sitting around with extra time on my hands, there's nothing like a online game for entertainment. I found this interesting JavaScript version of Battleship and decided to fancy it up a bit.
For starters, I practiced with some "onClick" code for the button to pop up a window in which to play the game in. The original game displayed your opponent's ships in the window status bar. That didn't suit since I was using a popup window. Snooping through the code I found the function that passed the status value (a variable named "statusmsg") and added one additional line: document.statusbox.display.value = statusmsg; (you gotta love DOM, eh?). The final touches were adding a form to the page (named "statusbox") and a readonly textarea (of course, named "display") and a handy little button that would call a function to reload the page when the game is over.
Credits for the original JavaScript are in the source code. It makes for good reading.
Addendum: After thinking about it for awhile, I realized that I didn't need a special function just to reload the game. Again, the DOM comes in handy and I simply used the reload method of the "location" object. Gee, isn't that easier?
So, give it a try:
May 30, 2002
May 23, 2002
Just in case you have not already learned how to utilize style sheets:
An Introduction to Cascading Style Sheets (CSS)
An Introduction to Cascading Style Sheets (CSS)
Does your site bite?
If nothing else, check out this article to make sure your site isn't one of the examples!
WebmasterBase - 10 Sites that Bite
If nothing else, check out this article to make sure your site isn't one of the examples!
WebmasterBase - 10 Sites that Bite
May 09, 2002
So, you've got a killer web site and you've outgrown that free web hosting package (you know the ones). What's next? Web Hosting Options
Web site confessional
Naw, we'd never do anything that would be considered bad design. No, not ever. (wink) Check out this article, just to make sure.
WebmasterBase - 10 Deadly Web Site Sins
Naw, we'd never do anything that would be considered bad design. No, not ever. (wink) Check out this article, just to make sure.
WebmasterBase - 10 Deadly Web Site Sins
Subscribe to:
Posts (Atom)