<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> withTest </title>
<meta charset="UTF-8">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
</head>
<body>
<div id="alertRet"> </div>
<script type="text/javascript">
self.alert=function(str){
var ret=document.getElementById("alertRet");
var element=document.createElement("div");
element.append(str);
ret.append(element);
};
function withTest() {
with (document) { //document的重复使用
writeln("Hello,");
writeln("it's a with keyword test!");
}
with (Math) { //Math的重复使用
alert(random());
alert(abs(-10));
}
}
withTest();
</script>
</body>
</html>
0.6695177875356813
10
Hello, it's a with keyword test!