Showing posts with label JavaScript. Show all posts
Showing posts with label JavaScript. Show all posts

Thursday, 7 June 2018

Chaudhari Karan

JavaScript – Placement

By     No comments:

JavaScript – Placement

Hello friends, In this lecture, we will discuss  JavaScript Placement.
JavaScript – Placement


There is the flexibility given JavaScript code anywhere in an HTML document. Here is the JavaScript in an HTML file are as follows:
  • ·         JavaScript in <head>...</head> section.
  • ·         JavaScript in <body>...</body> section.
  • ·         JavaScript in <body>...</body> and <head>...</head> sections.
  • ·         JavaScript in an external file and then in <head>...</head> section.

Here we place JavaScript in an HTML file in different ways.

JavaScript in <head>...</head> section

Example:
JavaScript in <head>...</head> section


Output:
JavaScript in <head>...</head> section

JavaScript in <body>...</body> Section

If JavaScript to run as the page loads so it is generates content in the page, then it is goes in the <body> portion of the document.

Example:
JavaScript in <body>...</body> Section

Output:
JavaScript in <body>...</body> Section

JavaScript in <body> and <head> Sections

Example:
JavaScript in <body> and <head> Sections

Output:
JavaScript in <body> and <head> Sections

JavaScript in External File


For more extensive work with JavaScript, find cases where are reusing identical JavaScript code on multiple pages of the site.

In multiple HTML files doesn't restrict to maintaining identical code. The script tag mechanism to store JavaScript in an external file and then include it into HTML files.   

Here is an example to include an external JavaScript file in HTML code using script tag and its src attribute.
JavaScript in External File


To use JavaScript as the external file source, then write JavaScript source code in the text file with the extension ".js".

For example, create JavaScript file with the name filename.js and then use the sayHello function in your HTML file after including the filename.js file.

JavaScript in External File


Read More

Tuesday, 5 June 2018

Chaudhari Karan

JavaScript – Enabling

By     No comments:

JavaScript – Enabling

Hello friends, In this lecture, we will discuss Enabling of JavaScript.
JavaScript – Enabling


All the browsers are supported by built-in JavaScript. In short, you need to enable or disable this support manually. Here it explains the procedure of enabling and disabling JavaScript support in browsers like Firefox, Chrome, Internet Explorer and Opera.


JavaScript in Firefox


Here are explains how to turn on or turn off JavaScript in Firefox:
  • Open the Firefox browser.
  • In new tab type about: config in the address bar.
  • Then you got the warning dialog in the browser.
  • Then find the list of configure options in the browser. 
  • Then type javascript.enabled in a search bar
  • Then click the option to enable or disable javascript by right-clicking.

JavaScript in Internet Explorer

Here are explains how to turn on or turn off JavaScript in Internet Explorer:
  • Open the Internet Explorer browser.
  • Click on Tools then go Internet Options from the menu.
  • Select Security tab from the dialog box.
  • Then click on the Custom Level button.
  •  Find the Scripting option.
  • Select Enable radio button under Active scripting.
  • Then click OK and come out.

To disable JavaScript support in Internet Explorer, select Disable radio button under Active scripting.

JavaScript in Chrome

Here are explains turn on or turn off JavaScript in Chrome:
  • Open the Chrome browser.
  • Click on the menu option.
  • Then go to Settings.
  • Click on the Show advanced settings.
  • In Privacy section, click on the Content settings button.
  • In the "JavaScript" section, select the option "Do not allow any site to run JavaScript" or "Allow all sites to run JavaScript (recommended)".

JavaScript in Opera

Here are explain how to turn on or turn off JavaScript in Opera:
  • Click on the Tools and select Preferences from the menu.
  • Then select Advanced option.
  • Click on the Content from the list
  • Then click on the Enable JavaScript check box.
  • Then click OK and come out.
  • To disable JavaScript support in Opera, not select the Enable JavaScript check box.

Warning for Non-JavaScript Browsers

If your browser does not support the JavaScript, then <noscript> tag is used for show any message in the browser.

Example:
JavaScript – Enabling, Warning for Non-JavaScript Browsers


In this example, if your browser does not support the JavaScript then <noscript> tag message will show. Otherwise, JavaScript code runs on the browser.
  

Read More

Sunday, 3 June 2018

Chaudhari Karan

JavaScript – Syntax

By     No comments:

JavaScript – Syntax

Hello friends, In this lecture we will discuss syntax of JavaScript.
JavaScript – Syntax


JavaScript using statements <script>... </script> HTML tags in a web page. JavaScript code placed between these tags.

JavaScript tags can place anywhere in web page, but it is recommended that should keep in <head> tags.

Example of JavaScript Tags:
JavaScript Tags

Two important attributes of script tag:

  • Language: This attribute specifies which scripting language are using. Its value will be JavaScript. But HTML and XHTML  have phased out the use of this attribute.
  • Type: This attribute is recommended to indicate the scripting language in use and its value set to "text/javascript".

So here is JavaScript syntax:

JavaScript Tags

First JavaScript Code


This is a sample example to print out "Hello World". It is added the optional HTML comment which is surrounds to JavaScript code. It is save the code from a browser that does not support JavaScript.
JavaScript comment ends with the “//-->”. In this program document.write function used for print.

Example:
JavaScript Code

Output:
JavaScript Print

Whitespace and Line Breaks


JavaScript language is ignores tabs, spaces, and newlines. That spaces, tabs, and newlines freely in program. It is free to format and indent program.

Semicolons are Optional


JavaScript simple statement are followed by a semicolon character, like C, C++, and Java. JavaScript allows  to omit this semicolon if statements are placed on a separate line.

Example:
JavaScript Semicolons


When formatted in a single line

JavaScript Semicolons

Case Sensitivity


JavaScript is the case-sensitive language. which means the keywords, variables, function names, and any other identifiers typed with a consistent capitalization of letters.

Example: Time and TIME are convey different meanings.

Comments in JavaScript

JavaScript supports C and C++-style comments.
  • Any text between a // is treated as a comment until the end of the line and it is ignored by JavaScript.
  • Any text between the/* and */ is a comment. It may span multiple lines.
  • HTML opening comment <!—also recognizes JavaScript. It is a single line comment like //.
  • HTML closing comment  --> is not recognized by JavaScript, but it written as //-->.


Comments in JavaScript

Read More

Friday, 1 June 2018

Chaudhari Karan

JavaScript Introduction

By     1 comment:

JavaScript Introduction

Hello friends, In this lecture, we will discuss the introduction of JavaScript.
JavaScript Introduction


JavaScript language is the dynamic, interpreted with an object-oriented programming language. It is commonly used in web pages.  It is designed client-side page for interact and make it dynamic pages.
First JavaScript was known as LiveScript, but Netscape changed the name to JavaScript because of the excitement generated by Java. JavaScript first appearance in Netscape 2.0 in 1995 with the name LiveScript.  

Specification of JavaScript language.

  •  JavaScript is the dynamic, interpreted programming language.
  •  JavaScript used for designed network-centric applications.
  •  JavaScript complementary and integrated with Java and HTML.
  •  It is Open and cross-platform.

Client-Side JavaScript


JavaScript language is the most common form of the client-side. It is included in or referenced by an HTML document for the code to be interpreted by the browser.

It means a web page doesn't need a static HTML, but it can include programs interact with a user, control the browser, and dynamically create HTML content.

The JavaScript language is client-side mechanism provides. It has many advantages over traditional CGI server-side scripts.
The JavaScript code is executed when entering the user valid information, it would be submitted to the Web Server.
JavaScript used to trap user-initiated events like button clicks, link navigation, and other actions, that is the user initiates explicitly or implicitly.
Advantages of JavaScript
  • Less server interaction: Validate user input sending before the page off to the server. It saves server traffic, it means less load on the server.
  • Immediate feedback to the visitors: User doesn't have to wait for the reload page.
  • Increased interactivity: Create interfaces for reacting the user hovers over with mouse or activates them via the keyboard.
  • Richer interfaces: JavaScript is included such items as drag-and-drop components and sliders to Rich Interface to your site visitors.

Limitations of JavaScript

  • Client-side JavaScript doesn't allow the reading or writing of files. It has kept for security.
  • JavaScript not used for networking applications because there is no support available.
  • JavaScript doesn't have multithreading or multiprocessor capabilities. 


JavaScript Development Tools


One of the most major strengths of JavaScript is it does not require any expensive development tools. It can start with the simple text editor such as Notepad or Notepad++. It is an interpreted language inside the context of a web browser. JavaScript doesn't need a compiler.
Here are some vendors JavaScript editing tools:
  • Microsoft FrontPage: It is a popular HTML editor called FrontPage. It also provides web developers with a number of JavaScript tools.
  • Macromedia Dreamweaver MX: It is a very popular HTML and JavaScript editor. It is the professional web development crowd. The tool provides some handy prebuilt JavaScript components, integrates well with databases, and conforms to new standards like XHTML and XML.
  • Macromedia HomeSite 5: It is a most-liked HTML and JavaScript editor. It is developed by Macromedia can be used to manage personal websites effectively.   


Read More