谁说window.form....这样调用不行?
另:window.getElementById("")...则会报错

解决方案 »

  1.   

    你加一个document就不会报错了:
     function sendvalue(mH,mM){
    var mObj=window.dialogArguments;
            var m=mObj.document.getElementsByName("SENDTEXT");
    alert(m[0].value);
    window.close();
      

  2.   

    window.showModalDialog
    你了解这个里面的参数吗?
      

  3.   

    还有接受的时候你都了解
    function sendvalue(mH,mM){ 
    var mObj=window.dialogArguments; 
            var m=mObj.getElementsByName("SENDTEXT"); 
    alert(m[0].value); 
    window.close(); 
    } 你直接这么用肯定是出错的
    一般都是这样document.getElementsByName("SENDTEXT");
    如果是承接上级的动作,那么前面的Obj应该放在下面,也就是Obj.document.getElementsByName("SENDTEXT");
      

  4.   

    javascript:alert(self.getElementsByName);alert(window.getElementsByName);void(0);你在浏览器地址栏输入上面的代码运行就知道了,self,window没有getElementsByName方法getElementsByName和getElementById是document对象的方法但是可以使用self,window或者document来引用images,frames,forms数组对象或者包含了name的frame,form单个对象self和window属性列表包含了document对象,所以2楼加document时就对了,而1楼会报错误楼主是没搞清楚self,window和document及他们拥有的方法和他们间的关系
      

  5.   

    <script>
    function show(){
    alert("self.test.value="+self.test.value);
    alert("window.test.value="+window.test.value);
    alert("document.form1.test2.value="+document.form1.test2.value);
    alert("test.value="+test.value);
    alert("document.all.test.value="+document.all.test.value);
    alert("document.test.value="+document.test.value);  //这一句出错
    }
    </script>
    <input name="test" type="text"/><input type="button" value="click me" onclick="show()"><form name="form1">
    <input name="test2" type="text"/>
    </form>
    上面几种调用方法,实在是有些不理解,为何document.test.value调用会出错呢?
    self,window,document,form,document.all与页面中各元素之间的是什么关系?具体该如何调用呢?
    即然元素存在页面中,为何document.test.value又错误呢?
    还请指点,谢谢!
      

  6.   

    document.test.value
    楼主,这你也用得出来,你得基础学哪去了啊???
    晕死了!虽然你的精神很可嘉。但是藐视基础。
    document.getElementsByName("test").value
    这个才是对的!
      

  7.   

    http://download.csdn.net/source/373109
    介绍一本书你看看。
      

  8.   

    self 值得是当前window窗体 ,实际上是在只有当前window == self  document 是窗体的一个文档,为XHTML DOM最高层 , 而form是表单,为document的子元素 document.all 是IE特有的写法,不是DOM标准 
    DOM推荐取值: document.getElementById(); document.getElementsByTagName();document.getElementsByName()
      

  9.   

    十分感谢各位大侠的指点!!看了javascript的权威指南和DHTML参考手册,但还是对javascript中的window和document二个对象的概念是有些不理解,还请指点!!为何window.test.value这个引用不会出错呢?
    window窗体与元素(text,button...),document与元素之间各是什么关系呢?是不是单个元素如text,button,checkbox是window的子元素,而不是document的子元素?
    而form,img也是document子元素?也就是可以document.form...来调用?还请各位大侠指点,谢谢!
      

  10.   

    http://download.csdn.net/source/373109 
    介绍一本书你看看。