JS为什么这样会报错?

lancky 2003-12-19 01:53:21
两个文件:
<a.asp>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>三</title>
<link href="css/css.css" rel="stylesheet" type="text/css">
</head>
<body>
<input type="button" value="pre" onclick="preview();">

</body>
<script language="javascript">
function preview() {
openwin = window.open("b.asp","_blank");
openwin.document.body.innerHTML="aaaa";

}
</script>
</html>

<b.asp>
<html>
<body>
<table>
<tr><td>dddd</td></tr>
</table>
</body>
</html>

为什么会报openwin.document.body为空或不是对象?
...全文
27 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
lancky 2003-12-22
  • 打赏
  • 举报
回复
这样的确可以了。
但是为什么新加的内容不能按样式表里的样式来显示呢?
bzscs 2003-12-21
  • 打赏
  • 举报
回复
<script language="javascript">
function preview() {
openwin = window.open("b.asp");
while(!openwin.document.body);
openwin.document.body.innerHTML="aaaa";

}
</script>
bzscs 2003-12-21
  • 打赏
  • 举报
回复
试试这个
<script language="javascript">
function preview() {
openwin = window.open("b.asp");
do while(!openwin.document.body);
openwin.document.body.innerHTML="aaaa";

}
</script>
lancky 2003-12-21
  • 打赏
  • 举报
回复
有人了解吗?
lancky 2003-12-19
  • 打赏
  • 举报
回复
我试了,但是还是不稳定,还是会报openwin.document.body为空或不是对象,
你可以试试将b.asp变成如下试试.

<b.asp>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>test</title>
<link href="css/css.css" rel="stylesheet" type="text/css">
</head>
<body>
<table>
<tr><td>dddd</td></tr>
</table>
</body>
</html>
shleo 2003-12-19
  • 打赏
  • 举报
回复
原来这样
xzq686 2003-12-19
  • 打赏
  • 举报
回复
果然,我这去掉就行,不会出现openwin.document.body为空或不是对象了!
xzq686 2003-12-19
  • 打赏
  • 举报
回复
不是时间的问题,是_bank的问题!你去掉_bank就行了!本来window.open就是弹出窗口!
<script language="javascript">
function preview() {
openwin = window.open("b.asp");
openwin.document.body.innerHTML="aaaa";

}
</script>
lancky 2003-12-19
  • 打赏
  • 举报
回复
我认为是时间的问题,
如何在preview()方法里,让OPEN动作后停顿1秒后再执行下面的动作?

28,407

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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