Inline, Internal, and External FIle

Slides:



Advertisements
Similar presentations
Essentials for Design JavaScript Level One Michael Brooks
Advertisements

Introduction to JavaScript
Introduction to JavaScript Module 1 Client Side JS Programming M-GO Sponsored By
The Web Warrior Guide to Web Design Technologies
COMPSCI 345 / SOFTENG 350 TUTORIAL WEEK 8 | SAM KAVANAGH.
Server-Side vs. Client-Side Scripting Languages
MSc. Publishing on WWW JavaScript. What is JavaScript? A scripting language devised by Netscape Adds functionality to web pages by: Embedding code into.
JavaScript- Introduction. What it is and what it does? What it is? It is NOT Java It is NOT Server-side programming Users can see code It is a client-side.
Intro to HTML Workshop. Welcome This slideshow presentation is designed to introduce you to the basics of HTML. It is the first of three HTML workshops.
Web Page Behavior IS 373—Web Standards Todd Will.
2012 •••••••••••••••••••••••••••••••••• Summer WorkShop Mostafa Badr
Introduction to JavaScript. Aim To enable you to write you first JavaScript.
Introduction to scripting
4.1 JavaScript Introduction
_______________________________________________________________________________________________________________ E-Commerce: Fundamentals and Applications1.
Introduction to JavaScript Dr. John P. Abraham University of Texas – Pan American.
SEG3210 DHTML Tutorial. DHTML DHTML is a combination of technologies used to create dynamic and interactive Web sites. –HTML - For creating text and image.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
Lesson 19. JavaScript errors Since JavaScript is an interpreted language, syntax errors will usually cause the script to fail. Both browsers will provide.
Fluency with Information Technology INFO100 and CSE100 Katherine Deibel Katherine Deibel, Fluency in Information Technology1.
JavaScript is a client-side scripting language. Programs run in the web browser on the client's computer. (PHP, in contrast, is a server-side scripting.
DHTML: Dynamic HTML Internet Technology1. What is DHTML? A collection of enhancements to HTML ► To create dynamic and interactive websites Combination.
SEG3210 DHTML Tutorial. DHTML DHTML is a combination of technologies used to create dynamic and interactive Web sites. –HTML - For creating text and image.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
What is Java Script? An extension to HTML. An extension to HTML. Allows authors to incorporate some functionality in their web pages. (without using CGI.
Lesson13. JavaScript JavaScript is an interpreted language, designed to function within a web browser. It can also be used on the server.
Client Side Programming with JavaScript Why use client side programming? Web sides built on CGI programs can rapidly become overly complicated to maintain,
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
Introduction.  The scripting language most often used for client-side web development.  Influenced by many programming languages, easier for nonprogrammers.
JavaScript - A Web Script Language Fred Durao
1 JavaScript
JavaScript Scripting language What is Scripting ? A scripting language, script language, or extension language is a programming language.
Cs332a_chapt10.ppt CS332A Advanced HTML Programming DHTML Dynamic Hypertext Markup Language A term describing a series of technologies Not a stand-a-lone.
Sahar Mosleh California State University San MarcosPage 1 JavaScript Basic.
Fluency with Information Technology INFO100 and CSE100 Katherine Deibel Katherine Deibel, Fluency in Information Technology1.
By Tharith Sriv. To write a web page you use: HHTML (HyperText Markup Language), AASP (Active Server Page), PPHP (HyperText Preprocessor), JJavaScript,
JavaScript Introduction.  JavaScript is a scripting language  A scripting language is a lightweight programming language  A JavaScript can be inserted.
HTML JAVASCRIPT. CONTENTS Javascript Example NOSCRIPT Tag Advantages Summary Exercise.
Scripting Languages Client Side and Server Side. Examples of client side/server side Examples of client-side side include: JavaScript Jquery (uses a JavaScript.
HTML Overview Part 5 – JavaScript 1. Scripts 2  Scripts are used to add dynamic content to a web page.  Scripts consist of a list of commands that execute.
JavaScript Challenges Answers for challenges
 Web pages originally static  Page is delivered exactly as stored on server  Same information displayed for all users, from all contexts  Dynamic.
Javascript Overview. What is Javascript? May be one of the most popular programming languages ever Runs in the browser, not on the server All modern browsers.
Learning Aim C.  Creating web pages involves many considerations.  In this section we will look at the different software tools you can use and how.
1 CSC160 Chapter 1: Introduction to JavaScript Chapter 2: Placing JavaScript in an HTML File.
CGS 3066: Web Programming and Design Spring 2016 Introduction to JavaScript.
JavaScript and Ajax (JavaScript Environment) Week 6 Web site:
JavaScript JavaScript is a programming language that web browsers understand. You can use it to make your web pages interactive by: Responding to user.
HTML Tutorial. What is HTML HTML is a markup language for describing web documents (web pages) HTML documents are described by HTML tags Each HTML tag.
Introduction to Web Site Development Department of Computer Science California State University, Los Angeles Lecture 9: JavaScript.
Web Programming Java Script-Introduction. What is Javascript? JavaScript is a scripting language using for the Web. JavaScript is a programming language.
OCR Computing OGAT Web Technologies. What OCR need you to know… You are expected to have a working knowledge of the above web languages.
G046 – Lecture 2A Recognising Web-Technologies Mr C Johnston ICT Teacher
Starting Out With JavaScript.  Due dates are listed on the ‘Schedule’ web page  Assignment #1 is due on Tuesday, April 19 Thursday, April 21 st at the.
Introduction to.
Javascript and Dynamic Web Pages: Client Side Processing
Chapter 5 Scripting Language
Active Server Pages Computer Science 40S.
Intro to JavaScript CS 1150 Spring 2017.
Chapter 5 Scripting Language
Introduction to JavaScript
DHTML Javascript Internet Technology.
A second look at JavaScript
DHTML Javascript Internet Technology.
Teaching slides Chapter 6.
Introduction to JavaScript
Introduction to Programming and JavaScript
CNIT 133 Interactive Web Pags – JavaScript and AJAX
Presentation transcript:

Inline, Internal, and External FIle Accessing JavaScript Inline, Internal, and External FIle

Accessing JavaScript in a Web Page Web browsers are built to understand HTML and CSS and convert those languages into a visual display on the screen. The part of the web browser that understands HTML and CSS is called the layout or rendering engine. But most browsers also have something called a JavaScript interpreter. That’s the part of the browser that understands JavaScript and can execute the steps of a JavaScript program. Since the web browser is usually expecting HTML, you must specifically tell the browser when JavaScript is coming by using the <script> tag. The <script> tag is regular HTML. It acts like a switch that in effect says “Hey, web browser, here comes some JavaScript code; you don’t know what to do with it, so hand it off to the JavaScript interpreter.” When the web browser encounters the closing </script> tag, it knows it’s reached the end of the JavaScript program and can get back to its normal duties.

Accessing JavaScript in a Web Page JavaScript can appear in several places: Inline (JavaScript inside a tag) Internal (JavaScript in a <script> tag) External (JavaScript in a separate file with a .js extension) Dynamic (In an external file loaded by JavaScript)

Inline JavaScript

Inline JavaScript Inline JavaScript appears inside an individual tag. The JavaScript commonly appears inside a event attribute, such as onClick (see below and next slide), or document.write (see Slide 7) <!DOCTYPE html> <html> <head> <title>Hello World 1</title> </head> <body> <form> <input type="button" value="Hello World" onClick="alert('Hello Yourself!')"> </form> </body> </html> http://faculty.cascadia.edu/cduckett/bit116/Lecture_04/helloworld1.html

Inline JavaScript <!DOCTYPE html> <html> <head> <title>Hello World 2</title> </head> <body> <p><a href="#" onClick="alert('Hello Yourself!')">Hello World</a></p> </body> </html> Notice how the a tag has two attributes (properties) with special values: href attribute is "#" although it might also be empty " ", or contain "javascript:; " - this disables normal link behavior onclick attribute is alert('Some Message'); - onclick is an event — the JavaScript runs when the event happens, in this case when the link receives a click http://faculty.cascadia.edu/cduckett/bit116/Lecture_04/helloworld2.html

Inline JavaScript <!DOCTYPE html> <html> <head> <title>Hello World 3</title> </head> <body> <p><a href="javascript:alert('Hello Yourself!')">Hello World</a></p> </body> </html> In this variation, the JavaScript is actually inside the href attribute. This is equivalent to the onClick example—we don’t need to explicitly specify the "click" event, because the href takes care of that for us. http://faculty.cascadia.edu/cduckett/bit116/Lecture_04/helloworld3.html

Inline JavaScript The above inline examples demonstrate a single line of JavaScript code—the alert() function—which displays a message in a modal dialog box. Inline JavaScript can be useful for certain specific tasks, but inline should be your third choice. External JavaScript files should be your first choice, internal JavaScript your second.

Internal JavaScript

Internal JavaScript Internal JavaScript appears inside a <script> tag, like this: <!DOCTYPE html> <html> <head> <title>Hello World 4</title> </head> <body> <h2>Hello World</h2> <script> // JavaScript goes here, between the opening and closing <script> tags. // Notice use of "//" comment style while in between the <script> tags. alert('Hello Yourself!'); </script> </body> </html> http://faculty.cascadia.edu/cduckett/bit116/Lecture_04/helloworld4.html

Internal JavaScript <!DOCTYPE html> <html> <head> <title>Hello World 5</title> </head> <body> <h2>Hello World</h2> <h2> <script> document.write("Hello Yourself!"); </script> </h2> </body> </html> http://faculty.cascadia.edu/cduckett/bit116/Lecture_04/helloworld5.html

Internal JavaScript <!DOCTYPE html> <html> <head> function popup() { alert("Hello Yourself!") } </script> </head> <body> <input type="button" onclick="popup()" value="Hello World"> </body> </html> http://faculty.cascadia.edu/cduckett/bit116/Lecture_04/helloworld6.html

External JavaScript File

External JavaScript File To use an external JavaScript file in a web page, use the <script> tag with the src attribute pointing to the JavaScript file. Example: <script src="somejavascript.js"></script> When using the <script> tag to load an external JavaScript file, do not also use the tag as a container for internal JavaScript — that is, do not put JavaScript (or anything thing else) between the opening tag and the closing tag. External JavaScript files are text files containing JavaScript, and nothing else. Edit using any text editor. Serious JavaScript developers typically edit files using an Integrated Development Environment (IDE) such as Dreamweaver or Komodo Edit. Do not use the <script> tag in an external JavaScript file itself — the <script> tag goes in the web page. When using two or more script tags on a page, the order of the tags can be significant, in terms of JavaScript processing.

Dynamic JavaScript “Dynamic” JavaScript Versus JavaScript Fundamentally, all JavaScript can be considered dynamic. All dynamic means in this context is that the script is performed on the client’s computer rather than on the server. However, “dynamic” most commonly refers to scripts that control, access, or manipulate HTML elements on the page. Dynamic JavaScript used to be called DHTML – Dynamic HTML – however, this term is rather misrepresentative of what’s really going on. DHTML is differentiated from Ajax by the fact that a DHTML page is still request/reload-based. With DHTML, there may not be any interaction between the client and server after the page is loaded; all processing happens in JavaScript on the client side. By contrast, an Ajax page uses features of DHTML to initiate a request (or 'subrequest') to the server to perform actions such as loading more content.