Web Basics ISYS546
Basic Tools Web server –Default directory, default home page –Virtual directory Web page editor –Front Page Web page languages –HTML, XML –Client-side script language: VBScript, JavaScript, DOM –Server-side language: VB.NET, ASP.NET
Dynamic Page – Client-Side Script Example Demo: TimeNowClient.Htm New Page 1 The time is now document.write time() iHour=hour(time()) if iHour < 12 then document.write " good morning " else document.write " good afternoon " end if
Dynamic Web Pages – Server-Side Script Example Demo: TimeNow.aspx – – The time is now –<% –dim iHour –iHour=hour(time()) –if iHour < 12 then –response.write “ good morning " –else –response.write " good afternoon " –end if –%>
Client-Side vs Server-Side Scripting Client-side scripting: –The browser requests a page. –The server sends the page to the browser. –The browser sends the page to the script engine. –The script engine executes the script. Server-side scripting: –The browser requests a page. –The server sends the page to the engine. –The script engine executes the script. –The server sends the page to the browser. –The browser renders the page. Demo: ShowSum.htm, Web Form
HTML Introduction Heading section –,,,, etc. Body section –,, to,, –Formatting:,,, –Comment: –List –Image –Table:, : a new row in table, : a new cell in a table row. –Form:,,,
Webpage Editor FrontPage demo Visual Studio.Net –Web Forms tab –HTML tab
META Tag The meta tag allows you to provide additional information about the page that is not visible in the browser: – Redirection: – “3” is number of seconds. Demo using FrontPage
TABLE Tag
FORM Tag Form attribute: –Action: Specify the URL of a program on a server or an address to which a form’s data will be submitted. –Method: Get: the form’s data is appended to the URL specified by the Action attribute as a QueryString. Post: A prefered method for database processing. Form’s data is sent separately from the URL. –Name: Form’s name Demo: TestFormGet.Htm, TestFormPost.Htm
QueryString A QueryString is a set of name=value pairs appended to a target URL. It can be used to pass information from one webpage to another. To create a QueryString: –Add a question mark (?) immediately after a URL. –Followed by name=value pairs separated by ampersands (&). Example:
Creating a QueryString Entered with a URL: – As part of a URL specified in an anchor tag. – Via a form sent to the server with the GET method.
SCRIPT Tag Client-side script: – <!-- statements --> Server-side script: – statements –
Document Object Model
Window Object The Window object represents a Web browser window. Properties: –window.status, window.defaultstatus –window.document, window.history, window.location. –Window.name Methods: –window.open (“url”, “name”, Options) Options: menubar=no, status=no, toolbar=no, etc. –window.close –window.alert(“string”) –window.prompt(“string”) –Window.focus –Etc.
Document Object The document object represents the actual web page within the window. Properties: –background, bgColor, fgColor, title, url, lastModified, domain, referrer, cookie, linkColor, etc. Ex. document.bgColor=“silver”; Methods: –Document.write (“string”) –Document.open, close Demo (testDoc.htm, docProp.htm)
Navigator Object The navigator object provides information about the browser. Properties: –Navigator.appName:browser name –Navigator.appCodeName: browser code name –Navigator.appVersion –Navigator.platform: the operating system in use.
Location Object Allows you to change to a new web page from within a script code. Properties: –Host, hostname, pathname –Href: full URL address –Search: A URL’s queryString Methods: – location.reload() To open a page:location.href = “URL”
Testing Location Object function openNew() site=window.prompt("enter url:") window.open (site) location.href="showformdata.htm" end function New Page 1 Note: TestLocation.Htm
History Object Maintain a history list of all the documents that have been opened during current session. Methods: – history.back() – history.forward() – history.go(): ex. History.go(-2) Demo: testDocOpenClose.htm
Testing the History Object <!-- sub clearVB() document.write ("hello, this is a new page") window.alert("Press any key to continue") document.open() document.write (" This is another new page ") document.close window.alert("Press any key to go back") history.go(-2) end sub --> New Page 1 this is old info document.write (" this is another old info ")
Client-side Scripting with the Browser Object Model window.status = "TestDomScript.Htm" New Page 1 document.write("you are using" & navigator.appName) document.write(" ") =window.prompt("Enter ") window.alert ("your enail is:" & ) site=window.prompt("enter url:") window.open (site) document.open() document.write("today is: " & Date())
HTML Tags and Events Link : click, mouseOver, mouseOut Image : abort(loading is interrupted), error, load. Area : mouseOver, mouseOut Body : blur, error, focus, load, unload Frameset: blur, error, focus, load, unload Frame: blur, focus Form: submit, reset Textbox, Text area: blur, focus, change, select Button, Radio button, check box: click List: blur, focus, change
Event Handler Event handler name: on + event name –Ex. onClick Three ways of writing handler: –1. Within the tag –2. Event function: onCLick=“clickHandler()” –3. Event procedure as in VB. Sub button1_onCLick()