JavaScript Tutorial/Dialogs/alert dialog
Содержание
Add a tab to alert box (IE)
<html>
<head>
<title>A Simple Page</title>
<script language="JavaScript">
<!--
alert("This line has a tab\there");
// -->
</script>
</head>
<body>
</body>
</html>
Add quotation marks to alert box
<html>
<head>
<title>A Simple Page</title>
<script language="JavaScript">
<!--
alert("\"That wasn\"t how it was at all!\" she said.");
// -->
</script>
</head>
<body>
</body>
</html>
Calcualtion in alert dialog
<html>
<head>
<title>A Simple Page</title>
<script language="JavaScript">
<!--
var a = 6, b = 4;
alert(a - b);
// -->
</script>
</head>
<body>
</body>
</html>
Start a new line in alert box in IE
<html>
<head>
<title>A Simple Page</title>
<script language="JavaScript">
<!--
alert("A carriage return lies right\rin the middle of this line!");
// -->
</script>
</head>
<body>
</body>
</html>
Use alert dialog box to display the content of an array
<html>
<head>
<title>A Simple Page</title>
<script language="javascript">
<!--
var days_of_week = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
alert(days_of_week);
// -->
</script>
</head>
<body>
</body>
</html>
Using alert Boxes
<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>