怎么设置window.open弹出的子窗口的title?

tlcd 2007-09-01 01:09:17
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的话。
...全文
2257 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
mbx615 2007-09-03
  • 打赏
  • 举报
回复
<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()">
mingxuan3000 2007-09-03
  • 打赏
  • 举报
回复
document.title ="123";
tlcd 2007-09-03
  • 打赏
  • 举报
回复
对了,tantaiyizu(痴情客)的方式我觉得最接近,我用self,就是: self.document.getElementsByTagName("title")[0].innerText = title;
这样不行,而且运行时这个语句肯定有错误产生,我在之后加上个alert语句都没反应,但是在看不出这个语句错在哪里了...?
tlcd 2007-09-03
  • 打赏
  • 举报
回复
我再说下,我的new.html是已经编辑好的文档,里面在<head></head>中间有<title></title>这个tag。我每次不同程序想通过window.open显示这个文档,但给它根据环境设置不同标题。所以不能用zhtf2014所用的直接写的方式。

LastGame的我试了,不行,窗口就跟固定了好了似的,一点标题变化都没有。

tantaiyizu(痴情客)的方式我觉得最接近,但因为这个子窗口是在父窗口里打开的,所以不该用opener吧,我用self,就是: self.document.getElementsByTagName("title")[0].innerText = title;
但也是不行....

我的父窗口和子窗口的用到的所有脚本都写在一个js文件中了,我觉得能让程序结构清楚些,不知道这个是不是产生异常的原因。不知道咋整了...
LastGame 2007-09-02
  • 打赏
  • 举报
回复
var oWin = window.open("new.html","myWindow","height=350,width=450,top=200,left=500");
oWin.title = "how are u ?";
tantaiyizu 2007-09-01
  • 打赏
  • 举报
回复
opener.document.getElementsByTagName("title")[0].innerText
zhtf2014 2007-09-01
  • 打赏
  • 举报
回复
<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>

mingxuan3000 2007-09-01
  • 打赏
  • 举报
回复
new.html里设置
boyle0630 2007-09-01
  • 打赏
  • 举报
回复
你可以在你要打開的頁面的<head></head>之間直接加<Title>標題</title>
如果標題是動態變化的就用一個變量

87,992

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧