Javascript: Web Engineering
Javascript: Web Engineering
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()
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.
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?
<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