WEB MEDIA SCHOOL session - 77 Java

Used wisely, it can take an ordinary site (even a personal site on a budget!) and make it extraordinary, and even for big e-commerce sites -- it helps close those extra sales and here's how:

Obviously, if you are on a tight budget (or even have a personal website), you may not have access to any scripting languages (such as .asp or .php3), or care to learn these additional languages. There are a lot of free websites where you can download simple 'premade' scripts, such as forms, cookies, clocks, and more -- in a a cut and paste fashion. (No backend scripting is required, unless youwant to!) ...It is also an excellent way to quickly and easily customize your webpage depending on browser settings (what kind of browser they are using, screen resolution, etc). Of course -- you can achieve the same effects with most backend languages -- however javascript is fast and easy, and does what is needed. ... If you have time sensitive information, or wish to display popup windows (for additional information), in many cases javascript is also an easy-to-implement solution.

For really serious development you would want to use java applets or a backend script, depending on your needs. Java applets are very good for the front-end/ graphical interface/user interaction, whereas the .php/.asp languages are very good for backend data management aspect, interfacing with databases, etc.

 Common Pitfalls to Avoid .... If you use .js files, make sure you have implemented them correctly! On some older browsers, all a user will get is your .js page (a listing of all your javascript), instead of your actual website (which can mean lost customers). ...If you use the newer versions of Javascript (i.e., say "1.2"), make sure your users are using the newest browsers. On older browsers, aside from numerous javascript errors (which again, can mean lost customers), it simply will not work. The easiest way to determine whether you are indeed *using* a newer javascript version is if you have to explicitly state what version you are using in the opening javascript tag. (I.e., "1.2"). ... Since javascript is compiled at 'run-time' (meaning as you view the webpage, the browser is figuring out what should happen with the javascript), so try and keep the code 'clean'. (I.e., avoid using nested loops when you don't need them -- your code will run faster) ... Try to keep the javascript code 'small' -- by using only the functions that you need. Some websites have so much unused javascript, that a simple webpage is over 100 KB, and takes a long time to load.

Effective Usage of Javascript ... If you are running *any* kind of e-commerce site with forms, javascript is almost always a must (for 'form verification'). Very often, it is easy for programmers to accidentally mix incorrect datatypes, that will result in errors and potentially lost sales. (For example, entering letters in a 'telephone number' field -- in many big e-commerce sites, the webpage will simply present the user with a cryptic "SQL Server Error: ..." message, and does *NOT* process their order!) ...If you use javascript for special FX (such as ticker tapes), in most cases only use one or two per webpages, otherwise your webpage can look quite cluttered.

 

 Conclusions ... By using Javascript wisely and effectively, you can add that superior element of design to your website, and impress all your visitors! ....Create javascripts easily and in seconds! Get the 1-2-3 JavaScript Library, and customize them to your needs, from http://www.wyka-warzecha.com/javascripts.php3

 Peter Thiruselvam, Editor, The WebProNews Team


The first step in setting up your JavaScript feed is to create the file that will contain your content. To do this, open a text editor such as Notepad and simply copy and paste your existing navigational setup into a new page. There is no need to begin the page with <HTML><HEAD>, etc. as you are only creating the feed for one section of your existing web page which already has those tags.

Once you've created your new page containing your navigational HTML, you'll now need to add some additional JavaScript coding to each line of your HTML. The first line of your new file will look like this:

<!--

The next line will begin with "document.writeln('" and end

with "');" (without the quotes). Your first line of HTML will be

placed between the beginning and ending coding. For every line

of your original coding, you'll need to add the above-mentioned

codes before and after. ... Note: Make sure you don't add any extra spaces, including at the

end of each line, as JavaScript is very sensitive.

Your new file will end with //--> on the last line. Here's how

your code might look:

<!--

document.writeln('<TABLE BORDER="0" ALIGN="Center">');

document.writeln('<TR>');

document.writeln('<TD>');

document.writeln('Your table content');

document.writeln('</TD>');

document.writeln('</TR>');

document.writeln('</TABLE>');

//-->

Each backslash (\) should be preceded with another backslash. ...Example: \\

Each apostrophe (') should be preceded with a backslash. ...Example: \'

You can include most HTML and JavaScript coding however, you cannot include JavaScript that must access another file to run.

After you've created your content and added the special JavaScript coding, you'll need to save your new file. Try to select a name that reflects your file such as navigate.js and make sure your filename is no longer than eight letters.

Next, you'll need to create a new directory on your server where you store your HTML files. Name this directory "content" (without the quotes) and upload your new .js file in ASCII.

Here's where the magic occurs - Place the following code in your HTML pages where you would like your navigate.js content to be displayed. Make sure you change the URL and direct it to your new .js file. The following code must be displayed exactly as it appears. Make sure there are no spaces after the first line of code.

<SCRIPT language="JavaScript"

src="http://www.yourdomain.com/content/yourfile.js"> </SCRIPT>

If you've followed the above steps correctly, your navigational system should now be displaying on your web page. If you are receiving a script error message, most of the time, it's due to an extra space at the end of a line or an extra or missing character. Make sure you go over your code very carefully. Once you've created your content feed and it is displaying your content, updating your file will be simple.

If you'd rather not have to code the JavaScript yourself, I use a great script called, Master Syndicator <http://hop.clickbank.net/hop.cgi?wsnet/willmaster> which will code your content for you. I highly recommend it.

Using JavaScript to display your navigational set up can not only enable you to instantly update the content on every page of your website, but can also save you hours of valuable time.

INDEX

NEXT PAGE

Music 
News
Health
 History
  Sports
Archaeology
Geography
 College Courses