put the code into window.onload, for examplehtml+="<SCRIPT language=javascript>function window.onload(){var arg2=createDatePicker(\"exes_Dates\",exes_datey,exes_datem,exes_dated);}</SCRIPT>";

解决方案 »

  1.   

    should not use "</SCRIPT>" in a javascript string;
    use "</SCR" + "IPT>" instead
      

  2.   

    如果你包含的JS文件中是有直接执行改变或读取对象的属性的语句而不是把这样的语句放在函数中调用的话是肯定会这样的错误的,因为你包含的代码是在要读取的对象的前面,当然会找不到对象啦,因为还没有把对象加载吗!试试把包含的JS文件放在后面:var html="";
      html+="<html><head>
      html+="<SCRIPT language=javascript>var arg2=createDatePicker(\"exes_Dates\",exes_datey,exes_datem,exes_dated);</SCRIPT>";
      html+="</body><SCRIPT language=javascript src=\"dateobject.js\"></SCRIPT></html>";
      document.frames("IFrame1").document.write(html);
      

  3.   

    用"<\/Script>"是个好写法。
    基本上是因为document.write出来的东西不会立刻生效的。
    可以这样:
    <script>
    document.write("<script src=aa.js><\/script>");
    </script>
    <script>
    func_in_aajs();
    </script>
      

  4.   

    insertAdjacentHTML Method--------------------------------------------------------------------------------Inserts the given HTML text into the element at the location.Syntaxobject.insertAdjacentHTML(sWhere, sText)
    ParameterssWhere Required. String that specifies where to insert the HTML text, using one of the following values: beforeBegin Inserts sText immediately before the object. 
    afterBegin Inserts sText after the start of the object but before all other content in the object. 
    beforeEnd Inserts sText immediately before the end of the object but after all other content in the object. 
    afterEnd Inserts sText immediately after the end of the object. 
     
    sText Required. String that specifies the HTML text to insert. The string can be a combination of text and HTML tags. This must be well-formed, valid HTML or this method will fail. Return ValueNo return value.ResIf the text contains HTML tags, the method parses and formats the text as it is inserted.You cannot insert text while the document is loading. Wait for the onload event to fire before attempting to call this method.When using the insertAdjacentHTML method to insert script, you must include the DEFER attribute in the script element. ExampleThis example uses the insertAdjacentHTML method to insert script into the page.var sHTML="<input type=button onclick=" + 
        "go2()" + " value='Click Me'><BR>"
    var sScript='<SCRIPT DEFER>'
    sScript = sScript + 
        'function go2(){ alert("Hello from inserted script.") }'
    sScript = sScript + '</script' + '>';
    ScriptDiv.insertAdjacentHTML("afterBegin",sHTML + sScript);