JavaScript DHTML/Language Basics/With — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Текущая версия на 07:24, 26 мая 2010
Using the with Statement in JavaScript
<html>
<head>
<title>JavaScript Unleashed</title>
</head>
<body>
<script type="text/javascript">
<!--
with(document){
write("Hello!");
write("<br>The title of this document is, \"" + title + "\".");
write("<br>The URL for this document is: " + URL);
write("<br>Now you can avoid using the object"s prefix each time!");
}
// -->
</script>
</body>
</html>
With statement
<html>
<head>
<title>A Simple Page</title>
<script language="JavaScript">
inp1 = 1;
inp2 = 2;
inp3 = 3;
with (Math)
{
alert("The largest number entered was " + max(inp1, inp2, inp3));
alert("The smallest number entered was " + min(inp1, inp2, inp3));
}
</script>
</head>
<body>
</body>
</html>