w = window.open("", window_name, 'toolbar=0,location=0, directories=0, status=0, menubar=0, scrollbars=1, resizable=1,copyhistory=0,width=900,height=600,top='+yOffset+',left='+xOffset+'');
w.document.write("<html><body><form method='POST' NAME='cForm' ID='cForm' enctype='multipart/form-data' >");
第二条语句出错,w为undefined,document对象为空,请问这里可以怎样做,谢谢啦!

解决方案 »

  1.   

    w = window.open("", window_name, 'toolbar=0,location=0, directories=0, status=0, menubar=0, scrollbars=1, resizable=1,copyhistory=0,width=900,height=600,top='+yOffset+',left='+xOffset+''); 
    这句话有错
      

  2.   

    你这样再试试.<script type="text/javascript">
    var window_name = '_blank';
    var xOffset = 100, yOffset = 20;w = window.open("", window_name, 'toolbar=0,location=0, directories=0, status=0, menubar=0, scrollbars=1, resizable=1,copyhistory=0,width=900,height=600,top=' + yOffset +',left='+xOffset+''); 
    w.document.write("<html> <body> <form method='POST' NAME='cForm' ID='cForm' enctype='multipart/form-data'>"); w.document.write("xyz");</script>
      

  3.   


    <script type="text/javascript">
    var w = window.open("about:blank");
    var wd = w.document.open();
    wd.write("hello,world!");
    wd.close();
    </script>
      

  4.   

    var window_name= "_self";
    var url= "1.html";
    var yOffset = 1000;
    var xOffset = 2000;
    debugger;
    w = window.open(url, window_name, 'toolbar=0,location=0, directories=0, status=0, menubar=0, scrollbars=1, resizable=1,copyhistory=0,width=900,height=600,top='+yOffset+',left='+xOffset+'');
    w.document.write(" <html> <body> <form method='POST' NAME='cForm' ID='cForm' enctype='multipart/form-data' >");
    你试试吧
      

  5.   

    我查了一下   好像没有 window.document 这个东西,建议楼主这样做,在打开的页面里写上<html><body onload=""></body></html> 
    然后在这个页面上用document.write
    不过你上面的那种想法也可以,就是这么取到打开窗口的问题,期待高手。
      

  6.   

    test.html<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Untitled Document</title>
    <script type="text/javascript">
    var s = window.open('3.html','','height=100, width=400, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no');
    s.document.open();
    s.document.write('<div style="color:red">=============================</div>');
    s.document.close();
    </script>
    </head>
    <body>
    </body>
    </html>
    3.html这个页面为空
      

  7.   

    上面的方法都试了,依然是document对象为空
      

  8.   

    试试最简单的
    var w = window.open("","test");
    setTimeout("w.document.write('aaaaaaaaa');",1000);
    若有问题,就是其它方面的问题了.
      

  9.   

    给你我写的详细的示例。
    http://blog.csdn.net/zhiqiangzhan/archive/2009/10/17/4686071.aspx#window