with Statementwith (object)
   statements 
Arguments
object 
The new default object. 
statements 
One or more statements for which object is the default object. 
Res
The with statement is commonly used to shorten the amount of code that you have to write in certain situations. In the example that follows, notice the repeated use of Math. x = Math.cos(3 * Math.PI) + Math.sin(Math.LN10) 
y = Math.tan(14 * Math.E)
When you use the with statement, your code becomes shorter and easier to read: with (Math){
   x = cos(3 * PI) + sin (LN10)  
   y = tan(14 * E)
}
Requirements
Version 1See Also
this Statement--------------------------------------------------------------------------------Send feedback to Microsoft© 2001 Microsoft Corporation. All rights reserved.

解决方案 »

  1.   

    with(document.body)
    {
      alert(innerHTML);  //等同于 alert(document.body.innerHTML);
    }with(document.formName)
    {
      alert(input1Name.value);
      alert(input2Name.value); //原理同上
    }
      

  2.   

    就是不共同的父体用一个代替了。
    with(学生)
       .姓名
       .年龄
      

  3.   

    with 语句
    为语句设定默认对象。 with (object)
       statements 参数
    object新的默认对象。statements一个或多个语句,object 是该语句的默认对象。说明
    with 语句通常用来缩短特定情形下必须写的代码量。在下面的例子中,请注意 Math 的重复使用: x = Math.cos(3 * Math.PI) + Math.sin(Math.LN10) 
    y = Math.tan(14 * Math.E)
    当使用 with 语句时,代码变得更短且更易读: with (Math){
       x = cos(3 * PI) + sin (LN10)  
       y = tan(14 * E)
    }