Lecture 6 8/11/11.

Slides:



Advertisements
Similar presentations
/ 251 Internet Applications Ahmed M. Zeki Sem – / Chapter 8.
Advertisements

Introducing JavaScript
CSS Layout Crash Course An Advance CSS Tutorial. Inline vs. Block Many HTML elements have a default display setting of Block. Block elements take up the.
Part 5 Introduction to CSS. CSS Display - Block and Inline Elements A block element is an element that takes up the full width available, and has a line.
The Web Warrior Guide to Web Design Technologies
9-May-15 More CSS. 2 A different emphasis CSS is the same for XML as it is for HTML and XHTML, but-- XML contains no display information If you want your.
14/11/11.  These words have special meanings in themselves  These should NOT be used as Identifiers.  For example:  Break, do, function, case, else,
1 Outline 13.1Introduction 13.2A Simple Program: Printing a Line of Text in a Web Page 13.3Another JavaScript Program: Adding Integers 13.4Memory Concepts.
Working with JavaScript. 2 Objectives Introducing JavaScript Inserting JavaScript into a Web Page File Writing Output to the Web Page Working with Variables.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
Tutorial 10 Programming with JavaScript
XP 1 Working with Cascading Style Sheets Creating a Style for Online Scrapbooks Tutorial 7.
XP 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial 10.
MORE Cascading Style Sheets (The Positioning Model)
XP Tutorial 1 New Perspectives on JavaScript, Comprehensive1 Introducing JavaScript Hiding Addresses from Spammers.
2012 •••••••••••••••••••••••••••••••••• Summer WorkShop Mostafa Badr
© Ms. Masihi 1.  A web page is created using a language called, Hypertext Markup Language, better known as HTML Code.  HTML is a user friendly language.
Introduction to scripting
Javascript and the Web Whys and Hows of Javascript.
Working with Cascading Style Sheets. Introducing Cascading Style Sheets Style sheets are files or forms that describe the layout and appearance of a document.
CS346 - Javascript 1, 21 Module 1 Introduction to JavaScript CS346.
JavaScript, Fifth Edition Chapter 1 Introduction to JavaScript.
UNIT 3 DYNAMIC WEBSITES WITH CSS AND JAVASCRIPT. OBJECTIVES  CO4 Apply style to a website using CSS.  CO5 Describe the use of scripting when creating.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad GM-IT CIIT Islamabad CIIT Virtual Campus, CIIT COMSATS Institute.
CSS Netcentric. What is CSS O CSS stands for Cascading Style Sheets O Styles define how to display HTML elements O Styles were added to HTML 4.0 to solve.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
A Basic Web Page. Chapter 2 Objectives HTML tags and elements Create a simple Web Page XHTML Line breaks and Paragraph divisions Basic HTML elements.
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
1 JavaScript in Context. Server-Side Programming.
XP Tutorial 10New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Working with JavaScript Creating a Programmable Web Page for North Pole.
TUTORIAL 10: PROGRAMMING WITH JAVASCRIPT Session 2: What is JavaScript?
Tutorial 10 Programming with JavaScript. XP Objectives Learn the history of JavaScript Create a script element Understand basic JavaScript syntax Write.
20-753: Fundamentals of Web Programming 1 Lecture 12: Javascript I Fundamentals of Web Programming Lecture 12: Introduction to Javascript.
Dr. Qusai Abuein1 Internet & WWW How to program Chap.(6) JavaScript:Introduction to Scripting.
ECA 225 Applied Interactive Programming1 ECA 225 Applied Online Programming basics.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
 2000 Deitel & Associates, Inc. All rights reserved. Outline 8.1Introduction 8.2A Simple Program: Printing a Line of Text in a Web Page 8.3Another JavaScript.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
XP Review 2 New Perspectives on JavaScript, Comprehensive1 Introducing Cascading Style Sheets Formatting Web Pages with CSS.
THE BOX MODEL Putting layouts together with CSS. The Box Model  How would you describe a box?  Container?  Tags or elements are “containers”  puts.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
1 JavaScript in Context. Server-Side Programming.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
Tutorial 10 Programming with JavaScript. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Learn the history of JavaScript.
JavaScript. JavaScript Introduction JavaScript is the world's most popular programming language. It is the language for HTML and the web, for servers,
Tutorial 10 Programming with JavaScript. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Learn the history of JavaScript.
- WE’LL LOOK AT THE POSITION PROPERTY AND HOW CSS RESOLVES CONFLICTS BETWEEN STYLING INSTRUCTIONS The position property; CSS specificity hierarchy.
Javascript Basic Concepts Presentation By: Er. Sunny Chanday Lecturer CSE/IT RBIENT.
REEM ALMOTIRI Information Technology Department Majmaah University.
JavaScript and AJAX 2nd Edition Tutorial 1 Programming with JavaScript.
XP Tutorial 10New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
INTERNET APPLICATIONS CPIT405 CSS Cascading Style Sheet Instructor: Omnia H. Alwazzan
Internet & World Wide Web How to Program, 5/e 1. 2.
Module 1 Introduction to JavaScript
Chapter 6 JavaScript: Introduction to Scripting
Introduction to Scripting
JavaScript.
Second CSS Lecture Applications to XML
MORE Cascading Style Sheets (The Positioning Model)
WEB PROGRAMMING JavaScript.
PHP.
T. Jumana Abu Shmais – AOU - Riyadh
More CSS 22-Feb-19.
Tutorial 10 Programming with JavaScript
Tutorial 10: Programming with javascript
JavaScript: Introduction to Scripting
Presentation transcript:

Lecture 6 8/11/11

Using Div Elements to create CSS layout Need to identify your documents sections Header Content Footer #header #content #container #footer Basic div structure used to make a single column layout

Div The <div> tag defines a division or a section in an xHTML document. The <div> tag is often used to group block-elements to format them with styles. <div id="header"> Specifies a unique id for an element Note: ids are used for the main elements of the page, such as header, main content, sidebar, footer, etc. Classes are used for elements that will appear several times on your page, but can not be covered by standard html elements. For example menus. The easy way to remember which one of the two should be used only once to think of how many people are out there with your id card number.

Div Example- One column layout <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <link rel="stylesheet" type="text/css" href="cssnew.css"/> <title>Divide Your Page</title> </head> <body> <div id="container"> <div id="header"> Hello World <!--This is where the header information is situated--> </div><!--close #header div--> <div id="content"> <!--This is where the main content information is situated--> </div><!--close #content div--> <div id="footer"> <!--This is where the footer information is situated --> </div><!--close #footer div --> </div><!--close #container div--> </body> </html> #container { width: 550px; background-color: #ffffff; } #header padding: 10 20px; background-color: #999999; #content background-color: #cccccc; #footer

Font Absolute and Relative Absolute sizes regardless of what the user does short of turning off style sheets - element's font size is locked If users try to resize text through their browsers, elements with an absolute font size won't change, but non-absolute elements will This prevents users from making your page's text larger if they need to see it more clearly, or smaller if they think it's too big.

Continued… W3C Relative units are: em: the 'font-size' of the relevant font ex: the 'x-height' of the relevant font px: pixels, relative to the viewing device The absolute units are: in: inches -- 1 inch is equal to 2.54 centimeters. cm: centimeters mm: millimeters pt: points -- the points used by CSS2 are equal to 1/72th of an inch. pc: picas -- 1 pica is equal to 12 points.

Positioning HTML elements are positioned static by default. A static positioned element is always positioned according to the normal flow of the page. Static positioned elements are not affected by the top, bottom, left, and right properties. An element with fixed position is positioned relative to the browser window. It will not move even if the window is scrolled e.g. watermark

Absolutely positioned elements can overlap other elements. CSS Positioning http://webdesign.about.com/od/advancedcss/a/aa061307.htm http://www.w3schools.com/cssref/playit.asp?filename=playcss_position&preval=relative The Positioning properties allow you to specify the left, right, top, and bottom position of an element It also allows you to set the shape of an element, place an element behind another, and to specify what should happen when an element's content is too big to fit in a specified area An absolute position element is positioned relative to the first parent element that has a position other than static. If no such element is found, the containing block is <html> Absolutely positioned elements are removed from the normal flow. The document and other elements behave like the absolutely positioned element does not exist. Absolutely positioned elements can overlap other elements. http://www.w3schools.com/css/css_colors.asp

Z-index Attribute Allows you to properly layer overlapping elements Elements that have a higher z-index value are displayed in front of elements with a lower value If you do not specify this value, elements that occur later in the document are displayed in front of those that occur earlier <html> <head><title>Absolute positioning</title> </head> <body> <img src="gates.gif" style="position: absolute; top: 0px; left: 0px; z-index:1"> <h1 style="position : absolute; top: 50px; left:50px; z-index: 3"> Position My Text</h1> <img src="beatles.gif" style="position: absolute; top:25px; left:600px; z-index:2"> </body> </html>

<html> <head> <style type="text/css"> h2 <html> <head> <style type="text/css"> h2.pos_left { position:relative; left:-20px; } h2.pos_right left:20px; </style> </head> <body> <h2>This is a heading with no position</h2> <h2 class="pos_left">This heading is moved left according to its normal position</h2> <h2 class="pos_right">This heading is moved right according to its normal position</h2> <p>Relative positioning moves an element RELATIVE to its original position.</p> <p>The style "left:-20px" subtracts 20 pixels from the element's original left position.</p> <p>The style "left:20px" adds 20 pixels to the element's original left position.</p> </body> </html> Relative Positioning A relative positioned element is positioned relative to its normal position. The content of relatively positioned elements can be moved and overlap other elements, but the reserved space for the element is still preserved in the normal flow.

What is JavaScript? JavaScript is a scripting language A JavaScript is lines of executable computer code A JavaScript can be inserted into an HTML page JavaScript is an open scripting language that anyone can use without purchasing a license

Javascript Developed by Netscape Communications (Microsoft’s version is called ‘Jscript’) Enables executable content within web pages on the client side Provides an alternative to VBScript for ASP programming on the server side (IIS)

Javascript JavaScript Text is just plain text, as is HTML JavaScript is not Java Can be used as a standalone or embedded in other languages or applications Major browsers contain a JavaScript interpreter

JavaScript When a JavaScript is inserted into an HTML document, the Internet browser will read the XHTML and interpret the JavaScript The JavaScript can be executed immediately or at a later event

Case Sensitivity JavaScript is a case-sensitive language Language keywords, variables, function names, and other identifiers must be typed with consistent capitalisation of letters Variable names script, Script, SCRIPT represent three different variables Note that xHTML is not case-sensitive

Whitespace and line breaks JavaScript ignores white spaces and line breaks with three exceptions If white space is in a value designated by quotes – “” or ‘’ If white space breaks up a token, i.e. a keyword, variable name, function name etc If a line breaks a statement e.g. if return true was put on two separate lines, this would be treated as two separate statements

Ending Statements with a Semicolon With the traditional programming languages C++ and Java, each code statement has to end with a semicolon Many programmers continue this habit when writing JavaScript, but in general, semicolons are optional and are required only if you want to put more than one statement on a single line

Whitespace and line breaks Simple statements in JavaScript are generally followed by a semi-colon barrier A=3; B=7; Or as below. A = 3; B = 7; Use of semi-colons is good programming practice.

Comments Browsers that don’t support JavaScript What happens when they hit the JavaScript code? We need to program around this. Older browsers that do not support scripts will display the script as page content. To prevent them from doing this, you can use the HTML comment tag. Comments are used to document code to increase programmer productivity and help maintenance efforts. // this is comment to the end of the line /* this would be used for a block of comment */

Example <html> <title>this is the title</title> <script language = “JavaScript”> <!--hide the script from non-JavaScript Browsers using an HTML comment SCRIPT GOES HERE // End the hiding comment --> </script> </html>

<title>First JavaScript Program</title> <html> <head> <title>First JavaScript Program</title> <script language="javascript"> document.writeln("<h1>Welcome to JavaScript Programming!</h1>"); </script> </head> <body> </body> </html>

Example JavaScript code goes into the HTML <head> tags. The language type is declared by <script language="javascript"> </script> document.writeln Instructs the browser’s JavaScript interpreter to perform an action, namely to display in the web page the string of characters between the double quotes (“ ”) The document object represents the HTML document currently being displayed in the browser It allows the programmer to specify HTML text to be displayed in the HTML document writeln is a method of the document object It contains the arguments that the method requires to perform it task or action

Data Types Probably the most fundamental aspect of a programming language JavaScript supports three primitive data types: Numbers strings of text Boolean values

Data Types Numbers: Boolean Values Integers (23 +-) Floating point (3.18 +-) Boolean Values Any binary value – true/false

Data Types Strings Other Data types Any sequence of characters in quotes Can be compare, concatenated and manipulated using operators “testing string 1” Other Data types Objects Arrays Exponential numbers Hexadecimal numbers The null value

Data Types First character must be a letter or an underscore _ Examples of Variables t My first variable IS6116 _harvest

Reserved Words Break, do, function, case, else, if, for, new… These words have special meanings in themselves These should NOT be used as Identifiers. For example: Break, do, function, case, else, if, for, new…

JavaScript Objects The browser contains a complete set of objects that allow script programmers to access and manipulate every element of a HTML document These objects reside in the computers memory and contains information used by the script Each object has attributes and behaviours associated with it

Variables A variable is a name associated with a data value A variable contains or stores the value Variables are names that have values assigned to them They provide a way to manipulate values by name

Assign a Value to a Variable You assign a value to a variable like this with the var statement: var strname = “Mary“ Or like this without the var statement: strname = “Mary“

Variables It is good programming practice to declare variables before using them var t; var sum; Or: var t; var sum; or var t = 2;

Untyped Variables T = 10; T = “ten”; int T = 10; String T = “ten”; Unlike other languages JavaScript is untyped Variables can hold data of any variable type T = 10; T = “ten”; In Java you would have to use: int T = 10; String T = “ten”; DataTypes can change accordingly

Example <html> <head> <script type="text/javascript"> function message() { alert("This alert box was called with the onload event"); } </script> </head> <body onload="message()"> </body> </html>