Total members 9951 | Gratitudes |It is currently Sat Feb 11, 2012 9:48 am Login / Join Codemiles


All times are UTC [ DST ]




Post new topic Reply to topic  Quick reply  [ 8 posts ] 
Author Question
 Question subject: what is javascript ?
PostPosted: Mon Oct 20, 2008 12:35 am 
Offline
Mastermind
User avatar

Joined: Tue Mar 27, 2007 10:55 pm
Posts: 2103
Location: Earth
Has thanked: 39 time
Have thanks: 56 time

What is JavaScript?

JavaScript is a compact, object-based scripting language for Web pages. JavaScript code embedded into your HTML pages can enhance them with many interesting elements, from swapping images when you move a cursor over them, to multi-level drop-down menus.

You can create really sophisticated and almost application-like pages with the help of JavaScript. You don't need any special software other than a text editor and a Web browser, and you don't need access to a Web server. You can create and test all your JavaScript code right on your own computer.

JavaScript and Java

Although the names are almost the same, JavaScript isn't the same as Java. These are two different techniques for Internet programming. Java is a real programming language, and you can create real programs with it.

JavaScript is a scripting language. You could even say that JavaScript is rather an extension to HTML than a separate computer language. It's so tightly integrated with HTML that you could call it "JavaScript markup language." JavaScript coders don't care too much about real programming, they just make different nice effects by inserting small JavaScript code fragments into their Web pages.

The drawbacks of JavaScript
Right now the biggest problem is the imperfect JavaScript implementations that today's browsers offer. Although all major browsers that are version 3.0 or higher include JavaScript support, they deal with JavaScript differently.

In fact, different versions of the same browser handle JavaScript differently. This makes it difficult to create a complicated JavaScript code that work across all browsers. So always check your pages on as many different browsers (and even platforms) as possible.

What do JavaScript code look like?
Like HTML, JavaScript is just text that can be typed into a text editor. Its code is embedded in HTML within a <SCRIPT> tag. Some old browsers don't understand this tag. To prevent them from treating your JavaScript as HTML, always use this trick involving HTML comments...

Code:
<script type="text/javascript">
<!-- hide JavaScript code from old browsers
YOUR SCRIPT HERE
// end the hiding comment -->
</script>


Here's an example of JavaScript code that prints current date in the top right corner of your Web page...
Code:
<html>
<head>
<script type="text/javascript">
<!--
function PrintDate() {
  today = new Date();
  document.write('Date: ', today.getMonth()+1, '/', today.getDate(), '/', today.getYear());
}
//-->
</script>
</head>

<body>
<p align="right">
<script type="text/javascript">
<!--
PrintDate();
//-->
</script>
</p>
THE REST OF YOUR PAGE.
</body>
</html>



The power of JavaScript
JavaScript has one particular feature that makes it an interactive and power tool - event handling. You can trigger the JavaScript program by various events. For example, when the page loads, when it quits, when you pass your cursor over a link, or when you click on a button or a link.

Here's a list of the common event handlers, that all popular browsers can deal with...

Event When it's triggered
onAbort An image is stopped from loading because the user either hits Stop or leaves the page.
onBlur An element, such as a window, frame, or form field, loses focus; that is, when the user clicks on something else.
onClick The user clicks on the particular element.
onChange The value of a form field changes, for example, when the user types in some data.
onDblClick The user double-clicks on the particular element.
onError A loading error happens, like a missing image.
onFocus The user puts the focus on the target element, by clicking on it or tabbing to it.
onKeyDown A key on the keyboard is pushed down, regardless of whether it's then held down or released.
onKeyPress This event is repeatedly triggered as long as a key is held down.
onKeyUp A key on the keyboard is released.
onLoad The browser completely loads the page.
onMouseDown A key on the mouse is pushed down, regardless of whether it's then held down or released.
onMouseMove The mouse moves.
onMouseOut The pointer moves out of the target area.
onMouseOver The pointer moves over the target element.
onMouseUp A key on the mouse is released.
onReset The Reset button of a form is clicked.
onResize A window or frame is resized by the user.
onSelect The user highlights text in a form field.
onSubmit A form is submitted.
onUnload The user leaves the page.

The basic event handling syntax is very simple. The following JavaScript code will pop up a window when you click a button...

Code:
<form>
<input type="button" value="Click me" onClick="alert('This is JavaScript!');">
</form>


If you need an elaborate action to take place when the button is clicked, you can call a predefined function. The following JavaScript code writes text to the statusbar (the bar on the bottom of your browser where the URLs are shown)...

Code:
function MyFunc( txt ) {
   window.status = txt;
}
<form>
<input type="button" value="Click me" onClick="MyFunc('This is JavaScript!');">
</form>

_________________
Currenlty programming with : java , html , php , and javascript . (OCJP-6 certified )


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: what is javascript ?
PostPosted: Sun Feb 15, 2009 4:02 pm 
Offline
Newbie
User avatar

Joined: Sun Feb 15, 2009 3:40 am
Posts: 6
Has thanked: 0 time
Have thanks: 0 time
Javascript is one of the most known language available in the internet, which is used by known companies like google and other known sites.


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: what is javascript ?
PostPosted: Wed Jul 22, 2009 11:56 am 
Offline
Newbie
User avatar

Joined: Wed Jul 22, 2009 11:07 am
Posts: 3
Has thanked: 0 time
Have thanks: 0 time
Hello,I have a confusion about JavaScript,that is if we are running a website which contains some flash content,simple HTML will that and a server script like PHP,then what is the use of Javascript over there ?Please explain me in details,I am very much confused.



_______________________________


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: what is javascript ?
PostPosted: Wed Aug 18, 2010 9:11 am 
Offline
Newbie
User avatar

Joined: Thu Jul 08, 2010 8:17 am
Posts: 2
Has thanked: 0 time
Have thanks: 0 time
Its nice to describe it...Thanks

_________________
http://www.visualsindia.com/


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: what is javascript ?
PostPosted: Wed Sep 22, 2010 11:47 am 
Offline
Newbie
User avatar

Joined: Tue Sep 07, 2010 9:18 am
Posts: 30
Has thanked: 0 time
Have thanks: 1 time
This post is very useful for those who are learning scripting languages...especially JavaScript.
All the basic things are here in this post...
Those who are interested should must go throw this.... :gOOd:

_________________
Robinetterie industrielle


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: what is javascript ?
PostPosted: Sun Jan 16, 2011 3:01 pm 
Offline
Beginner
User avatar

Joined: Sun Jan 09, 2011 2:16 pm
Posts: 54
Has thanked: 1 time
Have thanks: 0 time
arbaba wrote:
Hello,I have a confusion about JavaScript,that is if we are running a website which contains some flash content,simple HTML will that and a server script like PHP,then what is the use of Javascript over there ?Please explain me in details,I am very much confused.



_______________________________

java script is client side scripting....i.e there is no need to execute it in the server and reply it back to client..so the validation time and burden on server will reduce

_________________
technoyouth


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: what is javascript ?
PostPosted: Mon Jan 17, 2011 8:29 am 
Offline
Newbie
User avatar

Joined: Mon Jan 17, 2011 8:13 am
Posts: 1
Has thanked: 0 time
Have thanks: 0 time
Its nice to describe it...Thanks


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: what is javascript ?
PostPosted: Thu Mar 24, 2011 7:53 am 
Offline
Newbie
User avatar

Joined: Thu Mar 24, 2011 7:43 am
Posts: 1
Has thanked: 0 time
Have thanks: 0 time
The syntax of JavaScript will be simple to anyone who has ever programmed in an object oriented language. The primary object is the window, which is at the top of the hierarchy. Under that are the document, frame, location, history, and navigator objects. In turn, the document object contains anchors, applets, embeds, forms, images, and links, each of which is an array of objects. So, a reference to the first image on a page would be to self.document.image[0], although it is preferable to use names instead of numbers for clarity.

JavaScript is not a stand-alone language, but rather a scripting add-on to HTML. JavaScript is added to HTML commands by use of the <SCRIPT> tag. Anything within this tag is (or should be) ignored by browsers that do not support JavaScript. JavaScript is the most popular scripting language in use due to its cross-platform and cross-browser support, although VBScript is sometimes used on intranets when the scripter knows that everyone accessing the page is on Windows. JavaScript will attempt to execute the commands within the <SCRIPT> tag if there is no LANGUAGE attribute, or if the LANGUAGE attribute is set to JavaScript; in addition, the LANGUAGE attribute also can be used to distinguish between various versions of JavaScript.


TOP
 Profile Send private message  
Reply with quote  
Post new topic Reply to topic Quick reply  [ 8 posts ] 
Quick reply


  


 Similar topics
 Topic title   Forum   Author   Comments 
 Need to Display Content using JavaScript in HTML page  Scripting Language  stankov  0
 getting gst, pst total to diplay in my javascript form  Scripting Language  Anonymous  0
 need help with javascript  Scripting Language  triscuit  0
 Javascript select menu validation issue  Scripting Language  Anonymous  0
 validate age entered as selection box in javascript  JavaScript examples  msi_333  0

All times are UTC [ DST ]


Users browsing similar posts

Users browsing this forum: No registered users and 1 guest



Jump to:  
Previous Question | Next Question 




Home
General Talks
Finished Projects
Code Library
Games
Tutorials

Java
C/C++
C-sharp
php
Script
JSP/Servlets
Ajax
ASP/ASP.net
Google SEO
Database
Communications
Phpbb3 styles
Photoshop tutorials
Flash tutorials
Find a job






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team