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>
Related examples in the same category