Geekpedia Tutorials Home

Building a C# Chat Client and Server

Building a C# Chat Client and ServerA step by step tutorial teaching you how to create your own chat client and chat server easily in C#, for local networks or the Internet.

in C# Programming Tutorials

Getting Hard Drive Information

Getting Hard Drive InformationA C# tutorial showing you how to make use of WMI to extract information on disk drives, such as model, capacity, sectors and serial number.

in C# Programming Tutorials

UPS Shipping Calculator

UPS Shipping CalculatorThis tutorial will teach you how to calculate the shipping cost based on the weight, height, length and depth of the box, the distance and the UPS service type.

in PHP Programming Tutorials

Create Your Own Rich Text Editor

Create Your Own Rich Text EditorCreating a Rich Text Editor using JavaScript is easier to do than you might think, thanks to the support of modern browsers; this tutorial will walk you through it.

in JavaScript Programming Tutorials
Search
Tutorials
Programming Tutorials
IT Jobs
From CareerBuilder

Starting a JavaScript

How do you tell the browser that a script is starting? Moreover, how does he know what kind of script is starting? What if the browser doesn’t support JavaScript?

On Monday, March 8th 2004 at 10:35 AM
By Andrew Pociu (View Profile)
****-   (Rated 3.3 with 12 votes)
Contextual Ads
More JavaScript Resources
Advertisement

This is another fragment from the book I started some time ago, named 'JavaScript class'

Telling the browser JS is starting


We can’t tell the browser that a JavaScript is starting using some JavaScript code, because he doesn’t know, how to interpret it. We should tell the browser that a JavaScript code is starting that it says that another JavaScript is starting. That’s a paradox. Therefore, we must tell him using some usual code that all browsers can understand. That is HTML. We will use a HTML tag to tell the browser that JavaScript code is starting, and to send it to the JavaScript compiler implemented in the browser:


<script language=”JavaScript1.5” type=”text/javascript”>



Let’s take cut apart the code. It start with the usual ‘<’ HTML sign used to denote that a tag is starting. Then it uses ‘script’ to tell the browser a script is starting. ‘language=”JavaScript1.5”’ attribute is used to tell the browser more information about the script. And another attribute, ‘type=”text/javascript”’ means the same as the language attribute, but is used for compatibility reasons. Then the ‘>’ HTML tag-closing sign is used for telling the browser that the declaration is finished, but the script is just starting.
As any non-empty HTML tag, JavaScript tag has a closing tag, . So, the skeleton of our script looks like this until now:


<script language=”JavaScript1.5” type=”text/javascript”>
</script>



Language attribute


You saw in our script that we used an attribute that specified the language, and the language version: ‘language=”JavaScript1.5”’. We talked earlier in this book about JavaScript versions, and now we’re already applying the stuff we talked about. In the tag in which we are declaring that the script is starting, we can declare, as an attribute, the version that we use. If we specify an older version, for example JavaScript 1.3, the syntax will be checked as with an older interpreter, so if you use functions that are implemented in version 1.4 or earlier, the browser will most probably throw an error, even if it supports version 1.5.
Anyway, you’ll probably use the most recent version in your scripts, 1.5.

Pay attention if you want to use the first version of JavaScript, you must not write:


<script language=”JavaScript1.0” type=”text/javascript”>



The correct form is:


<script language=”JavaScript” type=”text/javascript”>



Don’t specify a version at all.

Two attributes for compatability
You saw that we used two attributes that do the same thing, and I said we must use them for compatibility:


language=”JavaScript”
type=”text/javascript”



Because none of this two attributes were marked as a standard, it’s better to use both of them. If you are sure that your target users use only Internet Explorer, for example, you can use only one of the attributes, because IE understands both of them. And that’s the ‘type=”text/javascript”’ attribute, because in the new XHTML language, the language attribute has been deprecated. I recommend you to use only this attribute; don’t waste your time with the language attribute.
For the start, we will use in our script both attributes, just for you to get familiar with them, but we will deprecate them on the road.

Hidding JS from older browsers


Yes, this is about compatibility again.
In the first days of JavaScript, when not all browsers had built-in support for understanding JavaScript, this code was very important. Now, because most of the browsers support JavaScript, and when I say most, I mean nearly every browser, you can safely discontinue using this improvised code. Let’s see how we can hide JS from old versions of browsers:


<!--
//-->



Yeah, it’s a HTML tag that represents a comment. Actually, it’s not entirely a HTML comment tag. It’s a HTML comment tag and two slashes, which represents a JavaScript comment. So, it’s a HTML comment combined with a JavaScript comment. You’ll learn more about comments in the upcoming lessons.
If the browser understands JavaScript, he will pass the comment, even if it’s commented with the HTML tags. If it doesn’t understand JavaScript, it will think that a comment is a comment, so he will not process it.
Older JavaScript programmers made a habit to comment their script, but now it’s no need too. Anyway, we will use it in our first examples, for the same reasons we use both declaration attributes, for you to get familiar.

Script skeleton


Here’s a very very very simple JavaScript script:


<html>
<head>
<title>Script skeleton</title>
<body>
<script language=”JavaScript1.5” type=”text/javascript”>
<!--
//-->
</script>
</body>
</html>


I call it very very very simple because it does nothing! Actually, this is just the skeleton that you must use every time you will write your script, except the comments, which we discussed earlier that are optional. You can write your script in an editor but it will do nothing.
Digg Digg It!     Del.icio.us Del.icio.us     Reddit Reddit     StumbleUpon StumbleIt     Newsvine Newsvine     Furl Furl     BlinkList BlinkList

Rate Rate this tutorial
Comment Current Comments
by ROSE on Wednesday, October 27th 2004 at 03:11 PM

i AM LOOKING ON WRITING SOME JAVASCRIPT BUT NEED A HELPING HAND IN THE RIGHT DIRECTION CAN YOU HELP?

by Andrei Pociu on Wednesday, October 27th 2004 at 03:13 PM

OK, you can post on the forums or contact me by email.

by noie on Friday, November 12th 2004 at 12:24 AM

your samples are just very simple, i need some difficults like accessing to the database..k? hop u wll.

by Andrei Pociu on Friday, November 12th 2004 at 01:31 AM

Accessing a database using JavaScript? ... I don't think so :) Maybe you want JSP (Java Server Page) or try PHP.

Read this: <a href-"http://www.webreference.com/programming/javascript/j_s/column9/" target="_blank">http://www.webreference.com/programming/javascript/j_s/column9/</a>

by me on Friday, March 18th 2005 at 02:55 AM

gv

by Firme de Mussa on Monday, June 19th 2006 at 04:49 AM

Hi! That\'s ok...But i\'am looking for new development tols in php programming and data base development by using MYSQL

by drifter on Tuesday, July 11th 2006 at 02:45 PM

hi im starting with java i dont know anyhting about it so if anybody that can help me n take time to help me or sen dme the codes i would be more then happy thnk u gefhf@yahoo.com email me if u can help me !

by agnes low on Friday, August 18th 2006 at 04:33 AM

Hi....I am looking the the use of javascript in my project. I need to ise the javascript to control the subjects direction. For example I want the subject turn left or right when it meet the conditions.
Can u help? Thanks

by sunglasses for glasses on Tuesday, August 2nd 2011 at 12:54 AM

Very interesting post. I like to share this post with my friends and book mark this interesting page. Keep it up.

by sunglasses for glasses on Tuesday, August 2nd 2011 at 12:57 AM

I am so grateful to read this such a wonderful post.

by sunglasses for glasses on Tuesday, August 2nd 2011 at 12:58 AM

I am so grateful to read this such a wonderful post.

by dr dre headphone on Thursday, August 25th 2011 at 02:42 AM

This is a very long story... I started shooting photos about 12 years ago. On the beginning I did mostly skating photos - those were sport pictures of my friends skaters. Later on I decided that I want to spread my horizons and I passed exams to Polish National Film School. From that time I started thinking about photography much more seriously - I decided that one day I will earn for my living by shooting photos

by dr dre headphone on Thursday, August 25th 2011 at 02:43 AM

I want to spread my horizons and I passed exams to Polish National Film School. From that time I started thinking about <a href="http://www.drdremonsterbeatsheadphones.com">dre headphone</a> photography much more seriously - I decided that one day I will earn for my living by shooting photos

by beats by dr dre on Wednesday, September 7th 2011 at 09:35 PM

I decided that one day I will earn for my living by shooting photos

by beats by dr dre on Wednesday, September 7th 2011 at 09:39 PM

I decided that one day I will earn for my living by shooting photos

by beats by dr dre on Wednesday, September 7th 2011 at 09:43 PM

I decided that one day I will earn for my living by shooting photos

by christian louboutin replica on Saturday, September 17th 2011 at 01:54 AM

<a href="http://www.christianlouboutinreplicacl.com/"><strong>christian louboutin replica</strong></a> or <a href="http://www.christianlouboutinreplicacl.com/"><strong>Christian Louboutin Knockoffs</strong></a> is one of the best choices for them to save money.Discount <a href="http://www.christianlouboutinreplicacl.com/"><strong>christian louboutin high heels</strong></a> online Sale with 60% off, And Christian Louboutin in 2011 new style hot sale,quality guarantee.

by moncler on Thursday, October 6th 2011 at 08:51 PM

Acheter à prix moins cher les produits <a href="http://www.monclerfemme-france.com"><strong>moncler</strong></a> avec www.monclerfemme-france.com.com Nos offres bottes <a href="http://www.monclerfemme-france.com"><strong>doudoune moncler</strong></a> sont mises à jour quotidiennement pour acheter pas cher vos produits préférés. Profitez la grande marque <a href="http://www.monclerfemme-france.com"><strong>doudoune moncler femme</strong></a> de bonne qualité. <a href="http://www.monclerfemme-france.com"><strong>doudoune moncler homme</strong></a>, classique, longue et courte. Livraison rapide, paiement sécurisé. Nous vous remercions de votre visite et nous espérons votre prochain achat.

by essay topics on Tuesday, October 18th 2011 at 11:13 AM

I recently came across your blog and have been reading along. I thought I would leave my first comment. I don't know what to say except that I have enjoyed reading. Nice blog. I will keep visiting this blog very often.

by particulier geld lenen on Thursday, October 27th 2011 at 04:41 AM

Very nicely written post it contains useful information for me. I am happy to find your distinguished way of writing the post. Now you make it easy for me to understand and implement the concept

by Replica watches on Monday, November 21st 2011 at 12:33 AM

in comparison to spending twenty to thirty thousand on an original Swiss-designed model. In addition, your watch will have the same look and feel of a real watch, and you will have thousands of dollars in savings. This situation is ideal in the event that you need an impressive and stylish luxury timepiece from a world-class brand name, but are not in a position to afford to buy one.

by buy louboutin on Friday, November 25th 2011 at 08:03 PM

This is good stuff. I just shared it on my FB page.

by satin black dress on Friday, November 25th 2011 at 08:04 PM

This is such a deep blog! What can I say, youve hit the nail right on the head! You even added some videos to make it seem so much more real. Youve got a great way of communicating with the reader, a great way of making me feel like what you have to say is just as important to me as it is to you. Keep it up!

by magazine subscriptions to Germany on Monday, December 12th 2011 at 04:51 AM

thank u for providing me information on List View.
I want to know how i can display data in datalist in Newsletter layout and Thank you so much, this is easy to understand and fun to continue along with. I am a migrating VB.NET/C# Developer looking for an insight into VC .NET. I've found the VC tutorials on many sites to be confusing, and the navigation around the sites to be near impossible to use! Thanks once again.

by Buy Capsiplex Plus on Sunday, January 1st 2012 at 10:18 PM

Thanks a lot mate, I have been looking for this guide for a long time, thanks!

by Capsiplex Plus on Sunday, January 1st 2012 at 10:18 PM

Thanks a lot mate, I have been looking for this guide for a long time, thanks!

by Capsiplex Plus on Sunday, January 1st 2012 at 10:18 PM

Thanks a lot mate, I have been looking for this guide for a long time, thanks!

by Capsiplex Plus on Sunday, January 1st 2012 at 10:18 PM

Thanks a lot mate, I have been looking for this guide for a long time, thanks!

by Addison on Monday, January 9th 2012 at 05:31 AM

Once you have recreated the problem and captured these steps, you can save them to a file and send it to your support person, who can then open it up and view

by gd poker gratis on Sunday, January 22nd 2012 at 03:35 PM

Hello.This post was really interesting, especially since I was browsing for thoughts on this topic last week.

by Marco Island Homes For Sale on Monday, February 6th 2012 at 12:30 AM

Thanks a lot mate, I have been looking for this guide for a long time, thanks!

by rida on Saturday, February 25th 2012 at 03:44 AM

Hi there! Do you use Twitter? I'd like to follow you if that would be ok. I'm undoubtedly enjoying your blog and look forward to new updates.
<a href="http://selfservebacklinks.com">link building service</a>

by rida on Saturday, February 25th 2012 at 03:45 AM

Hi there! Do you use Twitter? I'd like to follow you if that would be ok. I'm undoubtedly enjoying your blog and look forward to new updates.
<a href="http://selfservebacklinks.com">link building service</a>

by Galapagos TripsGalapagos Trips on Monday, February 27th 2012 at 07:41 AM

Your site always offer some really interesting information. Thank you for sharing it with us.

by hand scraped wood floors on Monday, February 27th 2012 at 07:59 AM

Good post....thanks for sharing.. very useful for me i will bookmark this for my future needs. Thanks.

by masini de inchiriat on Monday, March 5th 2012 at 02:52 PM

I enjoyed reading your articles. This is truly a great read for me. I have bookmarked it and I am looking forward to reading new articles. Keep up the good work!

by buy research papers on Wednesday, March 7th 2012 at 01:18 PM

Hi there! Do you use Twitter? I'd like to follow you if that would be ok. I'm undoubtedly enjoying your blog and look forward to new updates.

by camping tents for sale on Thursday, April 12th 2012 at 03:58 AM

I like this post, enjoyed this one regards for posting .


Comment Comment on this tutorial
Name: Email:
Message:
Comment Related Tutorials
There are no related tutorials.

Comment Related Source Code
There is no related source code.

Jobs JavaScript Job Search
My skills include:
Enter a City:

Select a State:


Advanced Search >>
Sponsors
Discover Geekpedia
Other Resources
Bargain EZ Tech Coupons & Deals