0% found this document useful (0 votes)
31 views17 pages

Javascript: Web Engineering

This document provides an overview of JavaScript, including: - JavaScript can be used for client-side and server-side scripting. It allows modifying web pages without posting back to the server. - JavaScript is a lightweight programming language used to make web pages interactive and insert dynamic content. - JavaScript differs from PHP in that it runs on the client-side browser while PHP runs on the server. - The document outlines common uses of JavaScript including changing HTML content and styles, hiding/showing elements, and different output methods like innerHTML, document.write(), and alerts.

Uploaded by

Shanza khursheed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views17 pages

Javascript: Web Engineering

This document provides an overview of JavaScript, including: - JavaScript can be used for client-side and server-side scripting. It allows modifying web pages without posting back to the server. - JavaScript is a lightweight programming language used to make web pages interactive and insert dynamic content. - JavaScript differs from PHP in that it runs on the client-side browser while PHP runs on the server. - The document outlines common uses of JavaScript including changing HTML content and styles, hiding/showing elements, and different output methods like innerHTML, document.write(), and alerts.

Uploaded by

Shanza khursheed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 17

JAVASCRIPT

Web Engineering
LEARNING OBJECTIVE
 At the end of this Lecture student will be able to understand client side & server side scripting
using JavaScript.
OUTLINE
 Why use client-side programming?  JavaScript Where To
 Why use server-side programming?  JavaScript Output
 Using innerHTML
 What is JavaScript?
 Using document.write()
 JavaScript vs. PHP  Using window.alert()
 Why Study JavaScript?  Using console.log()

 What JavaScript can do.


WHY USE CLIENT-SIDE
PROGRAMMING?
PHP already allows us to create dynamic web pages. Why also use client-side scripting?
 client-side scripting (JavaScript) benefits:
 usability: can modify a page without having to post back to the server (faster UI)
 efficiency: can make small, quick changes to page without waiting for server
 event-driven: can respond to user actions like clicks and key presses

CS380 4
WHY USE SERVER-SIDE
PROGRAMMING?
 server-side programming (PHP) benefits:
 security: has access to server's private data; client can't see source code
 compatibility: not subject to browser compatibility issues
 power: can write files, open connections to servers, connect to databases, ...

CS380 5
BASIS FOR COMPARISON SERVER-SIDE SCRIPTING CLIENT-SIDE SCRIPTING

Basic Works in the back end which could Works at the front end and script are
not be visible at the client end. visible among the users.

Processing Requires server interaction. Does not need interaction with the
server.

Languages involved PHP, ASP.net, Ruby on Rails, HTML, CSS, JavaScript, etc.
ColdFusion, Python, etcetera.

Affect Could effectively customize the web Can reduce the load to the server.
pages and provide dynamic
websites.

Security Relatively secure. Insecure


WHAT IS JAVASCRIPT?
 a lightweight programming language ("scripting language")
 used to make web pages interactive
 insert dynamic text into HTML (ex: user name)
 get information about a user's computer (ex: browser type)

CS380 7
WHAT IS JAVASCRIPT?
 a web standard (but not supported identically by all browsers)
 NOT related to Java other than by name and some similarities (JavaScript and Java are not the
same thing. They might share a similar name or syntax)

CS380 8
JAVASCRIPT VS. PHP
 similarities:
 both are interpreted.
 Because it is addressed to the browser, not to the CPU
 both are relaxed about syntax, rules, and types
 both are case-sensitive

CS380 9
JAVASCRIPT VS. PHP
differences:
 JS code runs on the client's browser; PHP code runs on the web
server

10
WHY STUDY JAVASCRIPT?

 JavaScript is one of the 3 languages all web developers must learn:


    1. HTML to define the content of web pages
    2. CSS to specify the layout of web pages
    3. JavaScript to program the behavior of web pages
WHAT JAVASCRIPT CAN DO.
 JavaScript Can Change HTML Content
 JavaScript Can Change HTML Attribute Values
 JavaScript Can Change HTML Styles (CSS)
 JavaScript Can Hide HTML Elements
 JavaScript Can Show HTML Elements
JAVASCRIPT WHERE TO
 The <script> Tag
 In HTML, JavaScript code must be inserted between <script> and </script> tags.

<script>
document.write("Hello World!");
</script>
Output:
Hello World!
 To use an external script:

<script src="myScript.js"></script>
JAVASCRIPT OUTPUT
 JavaScript can "display" data in different ways:
 Writing into an HTML element, using innerHTML.
 Writing into the HTML output using document.write().
 Writing into an alert box, using window.alert().
USING WINDOW.ALERT()
 You can use an alert box to display data:
REFERENCES
 Java Script & JQuery by Jon Duckett, Volume 2 (2014), ISBN-13: 978-1118531648, ISBN-
10: 9781118531648.
 W3Schools url: www.w3school.com
 TutorialsPoint url: www.tutorialpoint.com

You might also like