Javascript in Your WordPress Post Primer Tutorial

Javascript in Your WordPress Post Primer Tutorial

Javascript in Your WordPress Post Primer Tutorial

Today’s tutorial is ideally (designed) for the writers of blog posts who administer their blog’s content, and augments the content of NetBeans Java Web Application Primer Tutorial as shown below, to illustrate that within your WordPress (Blog) Posting you can include (dynamic) Javascript functionality. Today we do this with a WordPress (Blog) Posting that allows you to play a game of Noughts and Crosses (maybe you say Tic-Tac-Toe?!).

The advice I’d give about this (and could well apply to other CMS products other than WordPress) is listed below in point form (the one in bold itallics is the “get to the point” point):

  • If you are using a WYSIWYG (blog) post editor make sure you choose the HTML content option, to do with what follows.
  • In your embedded Javascript make sure there is no white space between your <script type=”text/javascript”> and what follows, and between your ending </script> and what follows, then place all this (Javascript) into the correct position of your (blog) posting HTML.
  • Test that this does not interfere with other functionality … reason for “is really for the writers of blog posts who administer their blog’s content” above.
  • A good way to “test” (as in point above) is to unit test your Javascript on a local webserver (like MAMP on a Mac or EasyPHP on Windows etcetera etcetera etcetera), and then separately test it integrated in with your actual (blog) website as a separate test before publishing.
  • You can get the gist of the nitty-gritty of today’s tutorial by looking at your View Page Source option on this browser session … Javascript of the (blog) posting starts at <script type=”text/javascript”>var cgoes=””;
  • You may ask, why are we talking about this? One reason is that lots of people would not want to touch, or are not permitted to touch (though that would be a bit weird for my (default) target audience?!), their (WordPress) theme code, and this method circumvents having to, but pretty obviously, won’t make you that cup of coffee before you even knew you wanted one, first thing (however, if I am wrong, can we do an app together?!).
  • Conversely, as a (blog) post administrator, you can see that perhaps if you have guest (blog) posting functionality maybe you should (within the WYSIWYG preferences) turn off the possibility of the use of <script> and </script> tags (ie. embedded Javascript).
     |           |           |           |           |           |     
     |           |           |           |           |           |     
     V           V           V           V           V           V     

You say Tic Tac Toe … I say Noughts and Crosses

New game


Previous NetBeans Java Web Application Primer Tutorial is relevant and shown below.

NetBeans Java Web Application Primer Tutorial

NetBeans Java Web Application Primer Tutorial

Today’s NetBeans Java Web Application primer tutorial builds on our previous Tic Tac Toe game shown below. We need to revisit this area of NetBeans to examine web Java Servlets, at a later date, because this Tic Tac Toe Java Web Application only goes so far as to use a JavaServer Page using JavaScript but Ajax, for instance, can be part of such functionality. In saying that, take a look at the last two slides of the tutorial to see that you can mix Java with HTML when you use JSP functionality.

Programming IDEs take a lot of the hard work out of tasks such as compiling and linking in languages such as Java, C, C++, VB.Net and C#. In the case of NetBeans IDE, which this blog reintroduces to you today (its customary to shake hands, and no Klingon is necessary), it can create a Java Web Application, for instance, as we do today to create a Tic Tac Toe game as a web application. To cut a long story short, there aint nothin’ wrong with a good ol’ IDE, but beware of IDEs in March.

In saying that about IDEs, and how they make programming easier, often with Open Source programming, it is advantageous to know what goes on “under the hood” (or even “in the ‘hood” … chortle, chortle). So if you ever get an opportunity to get helped creating your own makefile (or make it yourself, even with the Sweet Green Icing … knew it could be worked in!) for something, take the opportunity to learn how to do this, as the Open Source world will become a little easier to navigate with such types of knowledge. You’ve got to admire those early designers of computer languages, and those days when all you had was this tiny bit of memory (64k or “into the heliosphere on 8,000 bytes of memory”) to play with to create your program.

In doing this NetBeans Java Web Application found that Java JDK 1.6 needed to be upgraded to Java JDK 1.7 to allow for the workings of the GlassFish Web Server used by NetBeans, and, in order to do this, found How to upgrade JDK 1.6 to a higher version to run Glassfish? was incredibly helpful pointing to Java SE Downloads as the useful download area of interest.

NetBeans can be an IDE for much more than Java … it can supervise PHP, C++, Maven, Groovy and HTML/Javascript. In coming days and weeks we’ll look at more.

Link to downloadable NetBeans Java Web Application JavaServer Page programming source code at index.jsp

Link to NetBeans “spiritual home” download page at NetBeans.


Previous Tic Tac Toe game shown below.

New game

Here is a great movie scene that springs to mind.

If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.

This entry was posted in eLearning, Tutorials and tagged , , , , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *