window.open("new.html","myWindow","height=350,width=450,top=200,left=500");我这样打开的子窗口怎么没有标题,也设置不了标题阿?默认就是一个生硬的框,标题是Web Browser.怎么改也改不了。我试着在open的函数里加上其他的那些toolbar之类的选项为yes,不行。
我在这个子窗口的<body>里面加上启动事件:<body onload="set();">function set() {
self.document.title = "abcd";
}观察下,语句也正常无错执行了,可是弹出的子窗口还是什么都没有,只有个Web Browser的title.怎么才能加上合适的title那?如果用open的话。

解决方案 »

  1.   

    你可以在你要打開的頁面的<head></head>之間直接加<Title>標題</title>
    如果標題是動態變化的就用一個變量
      

  2.   

    <SCRIPT LANGUAGE="JavaScript">
    function openindex()
          { 
    OpenWindow=window.open("", "newwin", "height=250, width=250,toolbar=no,scrollbars="+scroll+",menubar=no");
    OpenWindow.document.write("<TITLE>Title Goes Here</TITLE>")
    OpenWindow.document.write("<BODY BGCOLOR=pink>")
    OpenWindow.document.write("<h1>Hello!</h1>")
    OpenWindow.document.write("This text will appear in the window!")
    OpenWindow.document.write("</BODY>")
    OpenWindow.document.write("</HTML>")OpenWindow.document.close()
    self.name="main"
         }
    </SCRIPT>
      

  3.   

    opener.document.getElementsByTagName("title")[0].innerText
      

  4.   

    var oWin = window.open("new.html","myWindow","height=350,width=450,top=200,left=500");
    oWin.title = "how are u ?";
      

  5.   

    我再说下,我的new.html是已经编辑好的文档,里面在<head></head>中间有<title></title>这个tag。我每次不同程序想通过window.open显示这个文档,但给它根据环境设置不同标题。所以不能用zhtf2014所用的直接写的方式。LastGame的我试了,不行,窗口就跟固定了好了似的,一点标题变化都没有。tantaiyizu(痴情客)的方式我觉得最接近,但因为这个子窗口是在父窗口里打开的,所以不该用opener吧,我用self,就是: self.document.getElementsByTagName("title")[0].innerText = title;
    但也是不行....我的父窗口和子窗口的用到的所有脚本都写在一个js文件中了,我觉得能让程序结构清楚些,不知道这个是不是产生异常的原因。不知道咋整了...
      

  6.   

    对了,tantaiyizu(痴情客)的方式我觉得最接近,我用self,就是: self.document.getElementsByTagName("title")[0].innerText = title;
    这样不行,而且运行时这个语句肯定有错误产生,我在之后加上个alert语句都没反应,但是在看不出这个语句错在哪里了...?
      

  7.   

    <script language="javascript">
    function testGG(){
    var xxx = window.open("new.html","myWindow","height=350,width=450,top=200,left=500");
    xxx.document.title = 'sdfe';}
    </script>
    <input type="button" value="open" onClick="testGG()">