46
PART 1 - Building a Static PART 1 - Building a Static Web Site Web Site HTTP Request/ HTTP Request/ Response Response HTML HTML DHTML DHTML Style Sheet Style Sheet Scripting Scripting

PART 1 - Building a Static Web Site HTTP Request/ Response HTTP Request/ Response HTML HTML DHTML DHTML Style Sheet Style Sheet Scripting Scripting

Embed Size (px)

Citation preview

Page 1: PART 1 - Building a Static Web Site HTTP Request/ Response HTTP Request/ Response HTML HTML DHTML DHTML Style Sheet Style Sheet Scripting Scripting

PART 1 - Building a Static PART 1 - Building a Static Web SiteWeb Site

HTTP Request/ HTTP Request/ ResponseResponse

HTMLHTMLDHTMLDHTML

Style Sheet Style Sheet ScriptingScripting

Page 2: PART 1 - Building a Static Web Site HTTP Request/ Response HTTP Request/ Response HTML HTML DHTML DHTML Style Sheet Style Sheet Scripting Scripting

Introduction to URLsIntroduction to URLs

Uniform Resource Locators (URL)Uniform Resource Locators (URL) Identifies location and protocol to Identifies location and protocol to

access a resourceaccess a resource URLs are a form of Uniform Resource URLs are a form of Uniform Resource

Identifier (URI)Identifier (URI)

Page 3: PART 1 - Building a Static Web Site HTTP Request/ Response HTTP Request/ Response HTML HTML DHTML DHTML Style Sheet Style Sheet Scripting Scripting

URL SyntaxURL Syntax

http://www.microsoft.com/ie

ftp://ftp.demon.co.uk

news:comp.infosys.www.announce

mailto:[email protected]

msdn.microsoft.com

http://www.microsoft.com/ie

ftp://ftp.demon.co.uk

news:comp.infosys.www.announce

mailto:[email protected]

msdn.microsoft.com

Scheme Path (scheme-specific format)

This is not a valid URL, but many browsers acceptit as equivalent to http:// msdn.microsoft.com

Page 4: PART 1 - Building a Static Web Site HTTP Request/ Response HTTP Request/ Response HTML HTML DHTML DHTML Style Sheet Style Sheet Scripting Scripting

HTTP URL FormatHTTP URL Format

http://www.microsoft.com/ie

http://www.microsoft.com:80/ie

http://www.wsdl.org.il

http://www.yahoo.com/index.html

http://www.microsoft.com/ie

http://www.microsoft.com:80/ie

http://www.wsdl.org.il

http://www.yahoo.com/index.html

Host name Port number. Defaults to 80.

An empty path refers to the home page(server-dependent: may be index.html or default.html)

Page 5: PART 1 - Building a Static Web Site HTTP Request/ Response HTTP Request/ Response HTML HTML DHTML DHTML Style Sheet Style Sheet Scripting Scripting

FTP HTTP TELNET

CLIENT

Ports in ActionPorts in ActionEach process uses a different port:Each process uses a different port:

TCP / UDP

IP

80 123421Port Number :

Page 6: PART 1 - Building a Static Web Site HTTP Request/ Response HTTP Request/ Response HTML HTML DHTML DHTML Style Sheet Style Sheet Scripting Scripting

HyperText Transfer HyperText Transfer Protocol (HTTP)Protocol (HTTP)

Application Level ProtocolApplication Level Protocol Technical information at Technical information at http://www.w3.orghttp://www.w3.org TCP-basedTCP-based Current version is 1.0Current version is 1.0

LightweightLightweight Easy to implement clients and serversEasy to implement clients and servers Stateless: each request is independent from the othersStateless: each request is independent from the others

Request/response paradigmRequest/response paradigm HTTP

TCP

IP

Network

Page 7: PART 1 - Building a Static Web Site HTTP Request/ Response HTTP Request/ Response HTML HTML DHTML DHTML Style Sheet Style Sheet Scripting Scripting

Finding a Web Server Finding a Web Server

http://www.google.com/options

DNS

TCP/IP

Web Server

GET /options HTTP/1.0

HTTP request:

•Wilkommen•Bienvenue•Welcome

Page 8: PART 1 - Building a Static Web Site HTTP Request/ Response HTTP Request/ Response HTML HTML DHTML DHTML Style Sheet Style Sheet Scripting Scripting

HTTP Request / HTTP Request / ResponseResponse

Client Request:Client Request: Method, Resource, HTTP versionMethod, Resource, HTTP version MIME type header and messageMIME type header and message

Server Response:Server Response: HTTP version and standard response codeHTTP version and standard response code MIME type header and messageMIME type header and message

40.0 Power

Turbo

Reset

GET /index.html HTTP/1.0GET /index.html HTTP/1.0

HTTP/1.0 0 200 OKContent-Length: 793Content-type: text/html<HTML>…</HTML>

HTTP/1.0 0 200 OKContent-Length: 793Content-type: text/html<HTML>…</HTML>

Client Web server

Page 9: PART 1 - Building a Static Web Site HTTP Request/ Response HTTP Request/ Response HTML HTML DHTML DHTML Style Sheet Style Sheet Scripting Scripting

HTTP RequestHTTP Request MethodMethod

Action to perform on resourceAction to perform on resource GET, HEAD, POSTGET, HEAD, POST

Uniform Resource IdentifierUniform Resource Identifier Identifies a networked resourceIdentifies a networked resource Absolute URI used with a proxy serverAbsolute URI used with a proxy server Request URI used with an origin serverRequest URI used with an origin server

HTTP VersionHTTP Version Major.minor versionMajor.minor version

MIME-like messageMIME-like message Contains request modifiers and forms dataContains request modifiers and forms data

Page 10: PART 1 - Building a Static Web Site HTTP Request/ Response HTTP Request/ Response HTML HTML DHTML DHTML Style Sheet Style Sheet Scripting Scripting

HTTP ResponseHTTP Response Simple Response/Full ResponseSimple Response/Full Response Status lineStatus line

HTTP version HTTP version Standard status codeStandard status code Reason phraseReason phrase

MIME like messageMIME like message Generated by Web server or by backend scriptGenerated by Web server or by backend script Header fields describe the requested resourceHeader fields describe the requested resource Modified using HTML <META> tagModified using HTML <META> tag Requested dataRequested data Header and Data are separated by Header and Data are separated by CRLF CRLF pairpair

Page 11: PART 1 - Building a Static Web Site HTTP Request/ Response HTTP Request/ Response HTML HTML DHTML DHTML Style Sheet Style Sheet Scripting Scripting

Building static web site Building static web site

o HTTPHTTPo Basic HTMLBasic HTMLo Images Images o Cascading Style Sheet Cascading Style Sheet o FormsFormso Client Scripting Client Scripting o Dynamic HTML Dynamic HTML

Page 12: PART 1 - Building a Static Web Site HTTP Request/ Response HTTP Request/ Response HTML HTML DHTML DHTML Style Sheet Style Sheet Scripting Scripting

Basic HTMLBasic HTML HTML Syntax HTML Syntax Paragraphs Paragraphs Lists Lists Hyperlinks Hyperlinks Frames Frames Tables Tables

Page 13: PART 1 - Building a Static Web Site HTTP Request/ Response HTTP Request/ Response HTML HTML DHTML DHTML Style Sheet Style Sheet Scripting Scripting

HTML PageHTML Page

<HTML>

<HEAD><TITLE>weclome wsttt</TITLE></HEAD>

<BODY>

Welcome to <B> WSTTT </B> course.<BR>

</BODY>

</HTML>

<HTML>

<HEAD><TITLE>weclome wsttt</TITLE></HEAD>

<BODY>

Welcome to <B> WSTTT </B> course.<BR>

</BODY>

</HTML>

Page 14: PART 1 - Building a Static Web Site HTTP Request/ Response HTTP Request/ Response HTML HTML DHTML DHTML Style Sheet Style Sheet Scripting Scripting

Attributes of TagsAttributes of Tags

<P>This is a normal paragraph.</P>

<P ALIGN=CENTER>This paragraph will be aligned in the centre of the page or screen.</P>

<P ALIGN="CENTER">This paragraph will be also be centred.</P>

<P>This is a normal paragraph.</P>

<P ALIGN=CENTER>This paragraph will be aligned in the centre of the page or screen.</P>

<P ALIGN="CENTER">This paragraph will be also be centred.</P>

Page 15: PART 1 - Building a Static Web Site HTTP Request/ Response HTTP Request/ Response HTML HTML DHTML DHTML Style Sheet Style Sheet Scripting Scripting

CommentsComments

<!-- Written by yair, 1/1/2003

Can you see me .. --><HTML><HEAD><TITLE>weclome wsttt</TITLE></HEAD><BODY>Welcome to <B> WSTTT </B> course.<BR></BODY></HTML>

<!-- Written by yair, 1/1/2003

Can you see me .. --><HTML><HEAD><TITLE>weclome wsttt</TITLE></HEAD><BODY>Welcome to <B> WSTTT </B> course.<BR></BODY></HTML>

Page 16: PART 1 - Building a Static Web Site HTTP Request/ Response HTTP Request/ Response HTML HTML DHTML DHTML Style Sheet Style Sheet Scripting Scripting

Special CharactersSpecial Characters How can we express characters like “<” and “>”?How can we express characters like “<” and “>”? Use character entitiesUse character entities

<< &lt;&lt; >> &gt;&gt; && &amp;&amp; "" &quot; &quot; (non-breaking space)(non-breaking space)&nbsp;&nbsp;

If the relative density &gt; 1.0 then &quot;you have a problem!&quot; If the relative density &gt; 1.0 then &quot;you have a problem!&quot;

If the relative density > 1.0 then "you have a problem!" If the relative density > 1.0 then "you have a problem!"

Page 17: PART 1 - Building a Static Web Site HTTP Request/ Response HTTP Request/ Response HTML HTML DHTML DHTML Style Sheet Style Sheet Scripting Scripting

Text FormattingText Formatting

<P>

<B>Bold</B>, <I>italic</I>, <U>underscored</U>.

</P>

<P>

<P>

<B>Bold</B>, <I>italic</I>, <U>underscored</U>.

</P>

<P>

Page 18: PART 1 - Building a Static Web Site HTTP Request/ Response HTTP Request/ Response HTML HTML DHTML DHTML Style Sheet Style Sheet Scripting Scripting

FontsFonts

<P><FONT SIZE="7">

<FONT FACE="Garamond, Times New Roman, Times"><I>The</I></FONT>

<FONT FACE="Arial Black, Arial, Helvetica"><B>News</B></FONT>

</FONT></P>

<P><FONT SIZE="7">

<FONT FACE="Garamond, Times New Roman, Times"><I>The</I></FONT>

<FONT FACE="Arial Black, Arial, Helvetica"><B>News</B></FONT>

</FONT></P>

Ahh ..<BIG>Ahh ..

<BIG>Ahh ..<BIG>Ahh ..

</BIG></BIG></BIG>

<SMALL><SMALL>Choo!</SMALL></SMALL>

Ahh ..<BIG>Ahh ..

<BIG>Ahh ..<BIG>Ahh ..

</BIG></BIG></BIG>

<SMALL><SMALL>Choo!</SMALL></SMALL>

Page 19: PART 1 - Building a Static Web Site HTTP Request/ Response HTTP Request/ Response HTML HTML DHTML DHTML Style Sheet Style Sheet Scripting Scripting

HeadingsHeadings

<H1>Agenda</H1>

<H2>Minutes of last meeting</H2>

<H2>Marketing report</H2>

<H3>Market survey</H3>

<H1>Agenda</H1>

<H2>Minutes of last meeting</H2>

<H2>Marketing report</H2>

<H3>Market survey</H3>

AgendaMinutes of last meeting

Marketing reportMarket survey

AgendaMinutes of last meeting

Marketing reportMarket survey

Page 20: PART 1 - Building a Static Web Site HTTP Request/ Response HTTP Request/ Response HTML HTML DHTML DHTML Style Sheet Style Sheet Scripting Scripting

ListsLists

<P>Shopping list:

<UL>

<LI>Eggs</LI>

<LI>Ham</LI>

<LI>Milk</LI>

</UL>

</P><P>The prize-winners are

<OL TYPE="1">

<LI>Colonel Pickering</LI>

<LI>Henry Higgins</LI>

<LI>Eliza Dolittle</LI>

</OL></P>

<P>Shopping list:

<UL>

<LI>Eggs</LI>

<LI>Ham</LI>

<LI>Milk</LI>

</UL>

</P><P>The prize-winners are

<OL TYPE="1">

<LI>Colonel Pickering</LI>

<LI>Henry Higgins</LI>

<LI>Eliza Dolittle</LI>

</OL></P>

Shopping list:

• Eggs

• Ham

• Milk

The prize-winners are

1. Colonel Pickering

2. Henry Higgins

3. Eliza Dolittle

Shopping list:

• Eggs

• Ham

• Milk

The prize-winners are

1. Colonel Pickering

2. Henry Higgins

3. Eliza Dolittle

Page 21: PART 1 - Building a Static Web Site HTTP Request/ Response HTTP Request/ Response HTML HTML DHTML DHTML Style Sheet Style Sheet Scripting Scripting

Horizontal RulesHorizontal Rules

<HR>

<HR NOSHADE ALIGN="CENTER" WIDTH="50%" SIZE="8">

<HR>

<HR NOSHADE ALIGN="CENTER" WIDTH="50%" SIZE="8">

Page 22: PART 1 - Building a Static Web Site HTTP Request/ Response HTTP Request/ Response HTML HTML DHTML DHTML Style Sheet Style Sheet Scripting Scripting

DivisionsDivisions

<DIV ALIGN=CENTER>

<H1>This is centered.</H1>

<H2>and so is this</H2>

<P>and so is this</P>

</DIV>

<DIV ALIGN=CENTER>

<H1>This is centered.</H1>

<H2>and so is this</H2>

<P>and so is this</P>

</DIV>

Page 23: PART 1 - Building a Static Web Site HTTP Request/ Response HTTP Request/ Response HTML HTML DHTML DHTML Style Sheet Style Sheet Scripting Scripting

HyperlinksHyperlinks

<A HREF="http://msdn.microsoft.com">GO</A>

<A HREF="http://msdn.microsoft.com">GO</A>

Page 24: PART 1 - Building a Static Web Site HTTP Request/ Response HTTP Request/ Response HTML HTML DHTML DHTML Style Sheet Style Sheet Scripting Scripting

SummarySummary

HTML standardsHTML standards Elements of HTMLElements of HTML Character and paragraph formattingCharacter and paragraph formatting ListsLists HyperlinksHyperlinks

Page 25: PART 1 - Building a Static Web Site HTTP Request/ Response HTTP Request/ Response HTML HTML DHTML DHTML Style Sheet Style Sheet Scripting Scripting

ImagesImages GIF, GIF Transparency, GIF GIF, GIF Transparency, GIF

Animation Animation JPG JPG Image Maps Image Maps

<IMG SRC=“pic1.gif" WIDTH=100 HEIGHT=100>

Page 26: PART 1 - Building a Static Web Site HTTP Request/ Response HTTP Request/ Response HTML HTML DHTML DHTML Style Sheet Style Sheet Scripting Scripting

FormsForms

Input FieldsInput Fields Text FieldText Field Text AreaText Area Radio ButtonsRadio Buttons Check BoxCheck Box List BoxList Box FileFile

Submitting FormsSubmitting Forms Method GET/POSTMethod GET/POST ActionAction Practicing on a predefine virtual dir with an ASPX Practicing on a predefine virtual dir with an ASPX

sample page sample page

Page 27: PART 1 - Building a Static Web Site HTTP Request/ Response HTTP Request/ Response HTML HTML DHTML DHTML Style Sheet Style Sheet Scripting Scripting

Cascading Style Cascading Style SheetSheet

Line spacing, Indents, Font sizes and Line spacing, Indents, Font sizes and colors colors

Tools for STYLE generation and Tools for STYLE generation and editing editing

In-Line STYLE In-Line STYLE Using CLASS tag to reference a Using CLASS tag to reference a

STYLE placed in the page head STYLE placed in the page head Using external CSS fileUsing external CSS file

Page 28: PART 1 - Building a Static Web Site HTTP Request/ Response HTTP Request/ Response HTML HTML DHTML DHTML Style Sheet Style Sheet Scripting Scripting

Embedded Style SheetsEmbedded Style Sheets

.. .. ..

<STYLE TYPE="text/css">

<!--

H1 { font-size: 15pt; font-weight:bold}

P { font: bold italic 12pt/20pt Times, serif}

-->

</STYLE>

.. .. ..

.. .. ..

<STYLE TYPE="text/css">

<!--

H1 { font-size: 15pt; font-weight:bold}

P { font: bold italic 12pt/20pt Times, serif}

-->

</STYLE>

.. .. ..

Page 29: PART 1 - Building a Static Web Site HTTP Request/ Response HTTP Request/ Response HTML HTML DHTML DHTML Style Sheet Style Sheet Scripting Scripting

Inline Style SheetsInline Style Sheets

<P STYLE="margin-left: 1in; margin-right: 1in; line-height:200%">

This text will be shown with one-inch left and right margins, and doublespaced.

</P>

<P>

This text is formatted as normal for &lt;P&gt; tags.

</P>

<P STYLE="margin-left: 1in; margin-right: 1in; line-height:200%">

This text will be shown with one-inch left and right margins, and doublespaced.

</P>

<P>

This text is formatted as normal for &lt;P&gt; tags.

</P>

Page 30: PART 1 - Building a Static Web Site HTTP Request/ Response HTTP Request/ Response HTML HTML DHTML DHTML Style Sheet Style Sheet Scripting Scripting

Using ClassesUsing Classes

<HEAD>

<STYLE TYPE=“text/css”><!--

P.red_caps {color:red; font-style: small-caps}

.blue_Arial {font-family: Arial; color: blue}

--></STYLE>

</HEAD>

<BODY>

<H1 CLASS=“blue_Arial”>This heading is in blue Arial</H1>

<P CLASS=“red_caps”>This text is in red and all small caps</P>

<P CLASS=“blue_Arial”>This text is in blue Arial, like the heading.</P>

</BODY>

<HEAD>

<STYLE TYPE=“text/css”><!--

P.red_caps {color:red; font-style: small-caps}

.blue_Arial {font-family: Arial; color: blue}

--></STYLE>

</HEAD>

<BODY>

<H1 CLASS=“blue_Arial”>This heading is in blue Arial</H1>

<P CLASS=“red_caps”>This text is in red and all small caps</P>

<P CLASS=“blue_Arial”>This text is in blue Arial, like the heading.</P>

</BODY>

Page 31: PART 1 - Building a Static Web Site HTTP Request/ Response HTTP Request/ Response HTML HTML DHTML DHTML Style Sheet Style Sheet Scripting Scripting

<SPAN> container<SPAN> container

Calling out <SPAN STYLE=“background: yellow; font-weight: bold; color: red”>special sections of text</SPAN> is possible using SPAN container.

Calling out <SPAN STYLE=“background: yellow; font-weight: bold; color: red”>special sections of text</SPAN> is possible using SPAN container.

<HEAD>

<STYLE TYPE=“text/css”><!--

SPAN {background: yellow; font-weight: bold; color: red}

--></STYLE>

</HEAD>

<BODY>

Calling out <SPAN>special sections of text</SPAN> is possible using SPAN container.

</BODY>

<HEAD>

<STYLE TYPE=“text/css”><!--

SPAN {background: yellow; font-weight: bold; color: red}

--></STYLE>

</HEAD>

<BODY>

Calling out <SPAN>special sections of text</SPAN> is possible using SPAN container.

</BODY>

Page 32: PART 1 - Building a Static Web Site HTTP Request/ Response HTTP Request/ Response HTML HTML DHTML DHTML Style Sheet Style Sheet Scripting Scripting

Using DivisionsUsing Divisions

<HEAD>

<STYLE TYPE=“text/css”><!--

.red_on_yellow {background: yellow; font-weight: bold; color: red}

--></STYLE>

</HEAD>

<BODY>

<DIV CLASS=“red_on_yellow” ALIGN=CENTER>

</DIV>

</BODY>

<HEAD>

<STYLE TYPE=“text/css”><!--

.red_on_yellow {background: yellow; font-weight: bold; color: red}

--></STYLE>

</HEAD>

<BODY>

<DIV CLASS=“red_on_yellow” ALIGN=CENTER>

</DIV>

</BODY>

Page 33: PART 1 - Building a Static Web Site HTTP Request/ Response HTTP Request/ Response HTML HTML DHTML DHTML Style Sheet Style Sheet Scripting Scripting

ID attributeID attribute

<H1 ID=“FirstHeading”>Welcome to WSTTT!<H1><H1 ID=“FirstHeading”>Welcome to WSTTT!<H1>

<HEAD>

<STYLE TYPE=“text/css”><!--

#FirstHeading {background: yellow; font-weight: bold; color: red}

--></STYLE>

</HEAD>

<BODY>

<H1 ID=“FirstHeading”>Welcome to WSTTT!<H1>

</BODY>

<HEAD>

<STYLE TYPE=“text/css”><!--

#FirstHeading {background: yellow; font-weight: bold; color: red}

--></STYLE>

</HEAD>

<BODY>

<H1 ID=“FirstHeading”>Welcome to WSTTT!<H1>

</BODY>

Page 34: PART 1 - Building a Static Web Site HTTP Request/ Response HTTP Request/ Response HTML HTML DHTML DHTML Style Sheet Style Sheet Scripting Scripting

Linking to a Style SheetLinking to a Style Sheet

<HEAD>

<LINK REL=STYLESHEET HREF="mystylesheet.css" TYPE="text/css">

</HEAD>

<HEAD>

<LINK REL=STYLESHEET HREF="mystylesheet.css" TYPE="text/css">

</HEAD>

Page 35: PART 1 - Building a Static Web Site HTTP Request/ Response HTTP Request/ Response HTML HTML DHTML DHTML Style Sheet Style Sheet Scripting Scripting

Client ScriptingClient Scripting The SCRIPT tag The SCRIPT tag Variables and Decision Making (if Variables and Decision Making (if

statement) statement) Using Functions Using Functions HTML generation (document. write) HTML generation (document. write) Events and FORM Validation Events and FORM Validation Error handling and Debugging Error handling and Debugging

Page 36: PART 1 - Building a Static Web Site HTTP Request/ Response HTTP Request/ Response HTML HTML DHTML DHTML Style Sheet Style Sheet Scripting Scripting

TheThe <SCRIPT><SCRIPT> Tag Tag

<SCRIPT LANGUAGE ="JavaScript"><!-- // Put your JavaScript here!//--></SCRIPT>

<SCRIPT LANGUAGE ="JavaScript"><!-- // Put your JavaScript here!//--></SCRIPT>

<SCRIPT LANGUAGE ="VBScript"><!-- ' Put your VBScript here!--></SCRIPT>

<SCRIPT LANGUAGE ="VBScript"><!-- ' Put your VBScript here!--></SCRIPT>

Page 37: PART 1 - Building a Static Web Site HTTP Request/ Response HTTP Request/ Response HTML HTML DHTML DHTML Style Sheet Style Sheet Scripting Scripting

Simple JavaScript Simple JavaScript ExampleExample

… <BODY>…Welcome to my web site!

<SCRIPT LANGUAGE="JavaScript"><!-- // My first JavaScript program alert("Welcome to JavaScript!");//--></SCRIPT>…</BODY></HTML>

… <BODY>…Welcome to my web site!

<SCRIPT LANGUAGE="JavaScript"><!-- // My first JavaScript program alert("Welcome to JavaScript!");//--></SCRIPT>…</BODY></HTML>

Page 38: PART 1 - Building a Static Web Site HTTP Request/ Response HTTP Request/ Response HTML HTML DHTML DHTML Style Sheet Style Sheet Scripting Scripting

Variables and Decision Variables and Decision MakingMaking

<SCRIPT LANGUAGE="JavaScript"><!-- var d = new Date(); var w = d.getDay(); var s;

if (w==0) s="Sunday"; if (w==1) s="Monday"; if (w==2) s="Tuesday"; if (w==3) s="Wednesday"; if (w==4) s="Thursday"; if (w==5) s="Friday"; if (w==6) s="Saturday"; alert(s);//--></SCRIPT>

<SCRIPT LANGUAGE="JavaScript"><!-- var d = new Date(); var w = d.getDay(); var s;

if (w==0) s="Sunday"; if (w==1) s="Monday"; if (w==2) s="Tuesday"; if (w==3) s="Wednesday"; if (w==4) s="Thursday"; if (w==5) s="Friday"; if (w==6) s="Saturday"; alert(s);//--></SCRIPT>

Page 39: PART 1 - Building a Static Web Site HTTP Request/ Response HTTP Request/ Response HTML HTML DHTML DHTML Style Sheet Style Sheet Scripting Scripting

Using FunctionsUsing Functions<SCRIPT LANGUAGE="JavaScript"><!--function ShowTheDay(){ var d = new Date(); var w = d.getDay(); var s;

if (w==0) s="Sunday"; if (w==1) s="Monday"; if (w==2) s="Tuesday"; if (w==3) s="Wednesday"; if (w==4) s="Thursday"; if (w==5) s="Friday"; if (w==6) s="Saturday"; alert(s);}//--></SCRIPT>

<SCRIPT LANGUAGE="JavaScript"><!--function ShowTheDay(){ var d = new Date(); var w = d.getDay(); var s;

if (w==0) s="Sunday"; if (w==1) s="Monday"; if (w==2) s="Tuesday"; if (w==3) s="Wednesday"; if (w==4) s="Thursday"; if (w==5) s="Friday"; if (w==6) s="Saturday"; alert(s);}//--></SCRIPT>

<SCRIPT LANGUAGE="JavaScript"><!-- ShowTheDay()//--></SCRIPT>

<SCRIPT LANGUAGE="JavaScript"><!-- ShowTheDay()//--></SCRIPT>

Page 40: PART 1 - Building a Static Web Site HTTP Request/ Response HTTP Request/ Response HTML HTML DHTML DHTML Style Sheet Style Sheet Scripting Scripting

HTML GenerationHTML Generationfunction ShowTheDay(){ var d = new Date(); var w = d.getDay(); var s;

if (w==0) s="Sunday"; if (w==1) s="Monday"; if (w==2) s="Tuesday"; if (w==3) s="Wednesday"; if (w==4) s="Thursday"; if (w==5) s="Friday"; if (w==6) s="Saturday"; document.write("Today is <B>" + s + "</B>");}

function ShowTheDay(){ var d = new Date(); var w = d.getDay(); var s;

if (w==0) s="Sunday"; if (w==1) s="Monday"; if (w==2) s="Tuesday"; if (w==3) s="Wednesday"; if (w==4) s="Thursday"; if (w==5) s="Friday"; if (w==6) s="Saturday"; document.write("Today is <B>" + s + "</B>");}

Page 41: PART 1 - Building a Static Web Site HTTP Request/ Response HTTP Request/ Response HTML HTML DHTML DHTML Style Sheet Style Sheet Scripting Scripting

Validation (1)Validation (1)

A form’s A form’s ONSUBMITONSUBMIT attribute is a attribute is a Boolean valueBoolean value Typically a script functionTypically a script function Returns true: form is valid and is Returns true: form is valid and is

submittedsubmitted Returns false: form is not valid and is Returns false: form is not valid and is

not submittednot submitted

<FORM METHOD="POST" NAME="DrinkSelector" ONSUBMIT="return isValidDrink(this)"><INPUT type="radio" checked name="RadioDrink" value="Tea">Tea<INPUT type="radio" name="RadioDrink" value="Coffee">Coffee<INPUT type="radio" name="RadioDrink" value="Soup">Soup<INPUT type="checkbox" name="CheckMilk" value="ON">Milk<INPUT type="checkbox" name="CheckSugar" value="ON">Sugar<INPUT type="submit" name="OKButton" value="Vend"> </FORM>

<FORM METHOD="POST" NAME="DrinkSelector" ONSUBMIT="return isValidDrink(this)"><INPUT type="radio" checked name="RadioDrink" value="Tea">Tea<INPUT type="radio" name="RadioDrink" value="Coffee">Coffee<INPUT type="radio" name="RadioDrink" value="Soup">Soup<INPUT type="checkbox" name="CheckMilk" value="ON">Milk<INPUT type="checkbox" name="CheckSugar" value="ON">Sugar<INPUT type="submit" name="OKButton" value="Vend"> </FORM>

Page 42: PART 1 - Building a Static Web Site HTTP Request/ Response HTTP Request/ Response HTML HTML DHTML DHTML Style Sheet Style Sheet Scripting Scripting

Validation(2)Validation(2)

function isValidDrink(theForm){ if (theForm.RadioDrink[2].Checked && (theForm.CheckMilk.Checked || theForm.CheckSugar.Checked)) { alert("You can't have milk or sugar with soup!"); return false; // Problem } else return true; // OK}

function isValidDrink(theForm){ if (theForm.RadioDrink[2].Checked && (theForm.CheckMilk.Checked || theForm.CheckSugar.Checked)) { alert("You can't have milk or sugar with soup!"); return false; // Problem } else return true; // OK}

Page 43: PART 1 - Building a Static Web Site HTTP Request/ Response HTTP Request/ Response HTML HTML DHTML DHTML Style Sheet Style Sheet Scripting Scripting

Dynamic HTMLDynamic HTML Dynamic Styles Dynamic Styles Changing Contents Changing Contents

Page 44: PART 1 - Building a Static Web Site HTTP Request/ Response HTTP Request/ Response HTML HTML DHTML DHTML Style Sheet Style Sheet Scripting Scripting

Sample 1/2Sample 1/2

<DIV id="DIV1" style="BACKGROUND-COLOR: powderblue"

onmouseover="DIV1_OnNouseOver()"onmouseout="DIV1_OnNouseOut()">Bring your mouse over here

</DIV>

<DIV id="DIV2“ style="BACKGROUND-COLOR: violet">and see the background changed here

</DIV>

Page 45: PART 1 - Building a Static Web Site HTTP Request/ Response HTTP Request/ Response HTML HTML DHTML DHTML Style Sheet Style Sheet Scripting Scripting

Sample 2/2Sample 2/2var DIV2_BackGround

function winOnLoad(){

DIV2_BackGround = DIV2.style.backgroundColor;}function DIV1_OnNouseOver(){

DIV2.style.backgroundColor = "royalblue";}

function DIV1_OnNouseOut(){

DIV2.style.backgroundColor = DIV2_BackGround;}

Page 46: PART 1 - Building a Static Web Site HTTP Request/ Response HTTP Request/ Response HTML HTML DHTML DHTML Style Sheet Style Sheet Scripting Scripting

What Next? – Web What Next? – Web ApplicationApplication

C#C#SQLSQLADO.Net ADO.Net ASP.NetASP.Net