JAVASCRIPT ALERT EXAMPLE 1:

</strong>

<HTML>
<HEAD>
<TITLE>Using alert Boxes</TITLE>
<SCRIPT LANGUAGE="JavaScript">
<!--
function displayer()
{
alert("Hello from JavaScript!")
}
//-->
</SCRIPT>
</HEAD>

<BODY>
<H1>Using alert Boxes</H1>
<FORM>
<INPUT TYPE="BUTTON" ONCLICK="displayer()" VALUE="Click Me!">
</FORM>
</BODY>
<HTML>

Prompt

<h2 align="center"><strong>JavaScript Confirm function</strong></h2>
&nbsp;

1

<html>
<head>
<title>A Simple Page</title>
<script language="javascript">
<!--
confirm("Which one will you choose?")
//  -->
</script>
</head>
<body>

</body>
</html>

Confirm function
<html>
<head>
<title>A Simple Page</title>
<script language="javascript">
<!--
confirm("Which one will you choose?")
//  -->
</script>
</head>
<body>

</body>
</html>

CONFIRM DIALOG RETURNS BOOLEAN VALUE:

<html>
<head>
<title>A Simple Page</title>
<script language="JavaScript">
<!--
var response = confirm("Do you want to proceed with this book?  Click OK to proceed otherwise click Cancel.");
alert(response)
//  -->
</script>
</head>
<body>

</body>
</html>

USE CONFIRM DIALOG IN IF STATEMENT:

<html>
<head>
<script Language="Javascript" type = "text/javascript">
<!--
var newurl

function CheckRequest(newurl)
{
if (confirm("Do you want to visit " + newurl + " site.")) {
return true
} else {
return false
}
}

//-->
</script>
<title>Capturing Links</title>
</head>
<P><A href="http://www.google.com" onClick = "return CheckRequest('java2s')">Java</A></P>
<P><A href="http://www.netscape.com" onClick = "return CheckRequest('Netscape')">Netscape</A></P>
</body>
</html>

Use confirms method in if statement:
<html>
<head>
<script language="JavaScript" type = "text/javascript">
<!--
var username = prompt("Type your name:", "");

if (confirm("Your name is: " + username + ". Is that correct?") == true )
{
alert("Hello " + username);
}
else
{
alert("Hi");
}
//-->
</script>
</head>
</html>

0 comments:

Post a Comment

 
Top
Blogger Template