Example Program Illustrate The Use of XHTML Meta Elements

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

1. example program illustrate the use of xhtml meta elements <head profile="http://dublincore.

org/documents/dcq-html/"> <title>Expressing Dublin Core in HTML/XHTML meta and link elements</title> <link rel="schema.DC" href="http://purl.org/dc/elements/1.1/" /> <link rel="schema.DCTERMS" href="http://purl.org/dc/terms/" /> <meta name="DC.title" lang="en" content="Expressing Dublin Core in HTML/XHTML meta and link elements" /> <meta name="DC.creator" content="Andy Powell, UKOLN, University of Bath" /> <meta name="DCTERMS.issued" scheme="DCTERMS.W3CDTF" content="2003-11-01" /> <meta name="DC.identifier" scheme="DCTERMS.URI" content="http://dublincore.org/documents/dcq-html/" /> <link rel="DCTERMS.replaces" hreflang="en" href="http://dublincore.org/documents/2000/08/15/dcq-html/" /> <meta name="DCTERMS.abstract" content="This document describes how qualified Dublin Core metadata can be encoded in HTML/XHTML &lt;meta&gt; elements" /> <meta name="DC.format" scheme="DCTERMS.IMT" content="text/html" /> <meta name="DC.type" scheme="DCTERMS.DCMIType" content="Text" /> </head> 2. write javascript that receives 3 integer from the user nd find the largest nd smallest from
them nd display the output in xhtml docu message box.
<?xml version ="1.0"?> <!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0 Strict//EN" "(URL address blocked: See forum rules)"> <html xmlns ="(URL address blocked: See forum rules)"> <head> <title>Performing Comparisons</title> <script type ="text/javascript"> var first, second, third, fourth, fifth, largest, smallest; first = window.prompt( "Enter first integer:", "0" ); second = window.prompt( "Enter second integer:", "0" ); third = window.prompt( "Enter third integer:", "0" );

fourth = window.prompt( "Enter fourth integer:", "0" ); fifth = window.prompt( "Enter fifth integer:", "0" ); document.writeln( "<h1>Comparison Results</h1>" ); document.writeln("<table border = \"1\" width = \"100%\">" ); largest=first; smallest=first; if (largest < second) document.writeln("<tr><td>" + largest + " < " + second + "largest less than second" + "</td></tr>" ); if (largest < third) document.writeln("<tr><td>" + largest + " < " + third + "largest less than third" + "</td></tr>" ); if (largest < fourth) document.writeln("<tr><td>" + largest + " < " + fourth + "largest less than fourth" + "</td></tr>" ); if (largest < fifth) document.writeln("<tr><td>" + largest + " < "+ fifth + "largest less than fifth" + "</td></tr>" ); if (smallest > second) document.writeln("<tr><td>" + largest + " > " + smallest + "largest less than second" + "</td></tr>" ); if (smallest > third) document.writeln("<tr><td>" + largest + " > " + smallest + "largest less than third" + "</td></tr>" ); if (smallest > fourth) document.writeln("<tr><td>" + largest + " > " + smallest + "largest less than fourth" + "</td></tr>" ); if (smallest > fifth) document.writeln("<tr><td>" + largest + " > " + smallest + "largest less than fifth" + "</td></tr>" ); document.writeln( "</table>" ); </script> </head> <body> <p>Click Refresh (or Reload) to run the script again</p> </body> </html>

3. write javascript func calculate garde() tat calculate student grade based on their avg of 5
marks.incorporatea script tat reads a value from the user.display the results of the function in browser.
<html> <head><title>Result</title> <script> function findResult(){ var result=""; var grade=""; var mm=document.form.marks.value; if(mm>90){ grade="A"; result="Passed"; } else if(mm>80&&mm<=90){ grade="B"; result="Passed" } else if(mm>70&&mm<=80){ grade="C"; result="Passed"; } else if(mm>60&&mm<=70){ grade="D"; result="Passed"; } else if(mm>50&&mm<=60){ grade="E"; result="Passed"; } else if(mm<=50){ grade="F"; result="Failed"; } document.writeln("Student Grade: <b>"+grade+"</b><br>"); document.writeln("Remarks: <b>"+result+"</b>"); } </script> </head> <form name="form"> Student Marks: <input type="text" name="marks"><br><br> <input type="button" value="Submit" onclick="findResult();"> </form>

4. write a prog to show the concept of cookies Cookies in ASP A cookie is a small piece of information that a server can store in a Web browser. Each time the browser requests a page from the server it sends the relevant cookies too. ASP allows you to create and retrieve cookies easily. Creating a Cookie

Cookies are created using Response.Cookies. Cookies are sent in the headers of the response so you should always set cookies before sending the body of the response. Example Cookie Creation <% Response.Cookies("username") = "earthskater" Response.Cookies("username").Expires = Date + 365 %> In the example above a cookie named "username" was created with a value of "earthskater". Then the expiry date was set using the Expires property. The cookie was set to expire 1 year from the days date. When the cookie expires it is deleted from the user's Web computer. Retrieving Cookies To retrieve cookies we use Request.Cookies. Example Cookie Retrieval <% username = Request.Cookies("username") response.write("Username: " & username) %> This code retrieves the value of the cookie named "username" and prints it in the browser. Note that cookies can be retrieved anywhere in the code, unlike creating them which has to be done before anything is written to the body of the response. Cookies with Multiple Values Cookies can also contain multiple values, using something called keys. Take a look at this example. <% Response.Cookies("user")("realname") = "John Doe" Response.Cookies("user")("username") = "johnny55" Response.Cookies("user")("age") = "55" %> This is fairly straightforward to understand. Retrieving the cookies is very simple too. <% realname = Response.Cookies("user")("realname") username = Response.Cookies("user")("username")

age = Response.Cookies("user")("age") %> Listing All Cookies You may want to list all the cookies available in a particular request. Here is how to do it. <% Dim x,y For Each x in Request.Cookies Response.Write("<p>") If Request.Cookies(x).HasKeys Then For Each y in Request.Cookies(x) Response.Write(x & ":" & y & "=" & Request.Cookies(x)(y)) Response.Write("<br />") Next Else Response.Write(x & "=" & Request.Cookies(x) & "<br />") End If Response.Write "</p>" Next %> The HasKeys property is used to check if a cookie has any keys.

You might also like