Professional Documents
Culture Documents
Web Designing Presentation 4 PDF
Web Designing Presentation 4 PDF
Web Designing
Semester - III
– Text Editor
– Browser
– To run JavaScript we need a compatible
browser like Netscape Navigator 2 .0 and up
• <SCRIPT LANGUAGE="javascript">
document.write("Hello, world")
</SCRIPT>
Output:
• Hello, world
• <script type="text/javascript">
<!-- // This is a single line JavaScript
comment
document.write("I have comments in my
JavaScript code!");
//document.write("You can't see this!"); //-->
</script>
• <head>
• <title>Data Types and Variables</title>
• </head>
• <body>
• <script type="text/javascript">
• x = 1024;
• document.write("<p>x = " + x + "</p>");
• x = “Peter";
• document.write("<p>x = " + x + "</p>");
• </script>
• </body>
• </html>
Alert(total_passenger);
</script>
Copyright @ Amity University
alert(), confirm(), and prompt()
functions
Alert
• confirm("sometext");
– +, -, /, % (arithmetic)
Syntax
• if (condition)
{
code to be executed if condition is true
}
• if (condition)
{
code to be executed if condition is true
}
else
{
code to be executed if condition is not
true
}
• switch (myColor)
• {
• case "Blue":
• document.write("Just like the sky!");
• break
• case "Red":
• document.write("Just like shiraz!");
• break
• default:
• document.write("Suit yourself then...");
• }
• //-->
• </script>
• </head>
• document.myform.text1.value"><BR>
• To Field <INPUT TYPE="text" NAME="text2">
• </FORM>
• </body>
• </html>
• </script>
• </head>
• <body>
• <form>
• <form>
• <input type="text" name="email_address"
• size="40" value="Please enter your email address"
• onfocus="this.value=''"/>
• </form>
• </body>
• </html>
Copyright @ Amity University
Output
• </script>
• </head>
• <body onload = "alert('Thanks for visiting my page!')">
• My Page
• </body>
• </html>
• My Page
score[0] = 35
score[1] = 56
score[2] = 10
sum=score[0]+score[1]+score[2];
alert(sum) ;
• function functionname(var1,var2,...,varX)
{
some code
}
• The parameters var1, var2, etc. are
variables or values passed into the
function. The { and the } defines the start
and end of the function.
</body>
</html>
Copyright @ Amity University
Thank You