往系统里注册了一个控件,写了个htm页来验证其是否注册成功,带<Object>的OpenWindow.document.write()那一行不能执行,提示<body onload="openwin(); closeWindow()"> 这一行缺少对象。将带<Object>的行去掉,其它都能执行。请大家帮忙看看,是怎么回事?谢谢了。<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" >
<title> </title>
<script LANGUAGE="Javascript"type="text/javascript">
function openwin() //弹出窗口的函数
{
OpenWindow=window.open("", "newwin", "top=200, left=300, height=400, width=600,toolbar=no,sc rollbars="+scroll+",menubar=no");
OpenWindow.document.write("<HTML>")
OpenWindow.document.write("<TITLE>检测安装是否成功</TITLE>")
OpenWindow.document.write("<BODY BGCOLOR=#ffffff>")
OpenWindow.document.write("<p align='center'>【检测报表控件安装是否成功】</p>")
OpenWindow.document.write("<p>◆下面的报表页面如能正常显示,则表示控件已成功安装;否则表示未成功安装。</p>")
OpenWindow.document.write("<p>◆现在请关闭本窗口以完成后续安装;如未成功请重启电脑再安装一次!</p>")
OpenWindow.document.write("<p align='center'>", "<OBJECT CLASSID="Clsid:871D9E6D-F501-456D-8503-9DC1550B5519" id="UFCell" width="98%" height="70%" align="center" hspace="0" vspace="0" >","<param name="RpCellMode" value="2">","</OBJECT>","</p>")
OpenWindow.document.write("</BODY>")
OpenWindow.document.write("</HTML>")
OpenWindow.document.close()
}
</script>
<script language="JavaScript" type="text/javascript">
function closeWindow() //关闭本窗口的函数
{
window.opener=null;
window.open('', '_self', '');
window.close();
}
</script>
</head>
<body onload="openwin(); closeWindow()"> //弹出窗口后,关闭本窗口
</body>
</html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" >
<title> </title>
<script LANGUAGE="Javascript"type="text/javascript">
function openwin() //弹出窗口的函数
{
OpenWindow=window.open("", "newwin", "top=200, left=300, height=400, width=600,toolbar=no,sc rollbars="+scroll+",menubar=no");
OpenWindow.document.write("<HTML>")
OpenWindow.document.write("<TITLE>检测安装是否成功</TITLE>")
OpenWindow.document.write("<BODY BGCOLOR=#ffffff>")
OpenWindow.document.write("<p align='center'>【检测报表控件安装是否成功】</p>")
OpenWindow.document.write("<p>◆下面的报表页面如能正常显示,则表示控件已成功安装;否则表示未成功安装。</p>")
OpenWindow.document.write("<p>◆现在请关闭本窗口以完成后续安装;如未成功请重启电脑再安装一次!</p>")
OpenWindow.document.write("<p align='center'>", "<OBJECT CLASSID="Clsid:871D9E6D-F501-456D-8503-9DC1550B5519" id="UFCell" width="98%" height="70%" align="center" hspace="0" vspace="0" >","<param name="RpCellMode" value="2">","</OBJECT>","</p>")
OpenWindow.document.write("</BODY>")
OpenWindow.document.write("</HTML>")
OpenWindow.document.close()
}
</script>
<script language="JavaScript" type="text/javascript">
function closeWindow() //关闭本窗口的函数
{
window.opener=null;
window.open('', '_self', '');
window.close();
}
</script>
</head>
<body onload="openwin(); closeWindow()"> //弹出窗口后,关闭本窗口
</body>
</html>
改成
document.write("<p align='center'><OBJECT CLASSID='Clsid:871D9E6D-F501-456D-8503-9DC1550B5519' id='UFCell' width='98%' height='70%' align='center' hspace='0' vspace='0' >'<param name='RpCellMode' value='2'></OBJECT></p>")
试试
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" >
<title> </title>
<script type="text/javascript">
function openwin() //弹出窗口的函数
{
OpenWindow=window.open("", "newwin", "top=200, left=300, height=400, width=600,toolbar=no,sc rollbars="+scroll+",menubar=no");
OpenWindow.document.write("<HTML>")
OpenWindow.document.write("<TITLE>检测安装是否成功</TITLE>")
OpenWindow.document.write("<BODY BGCOLOR=#ffffff>")
OpenWindow.document.write("<p align='center'>【检测报表控件安装是否成功】</p>")
OpenWindow.document.write("<p>◆下面的报表页面如能正常显示,则表示控件已成功安装;否则表示未成功安装。</p>")
OpenWindow.document.write("<p>◆现在请关闭本窗口以完成后续安装;如未成功请重启电脑再安装一次!</p>")
OpenWindow.document.write("<p align='center'>")
OpenWindow.document.write("<OBJECT CLASSID='Clsid:871D9E6D-F501-456D-8503-9DC1550B5519' id='UFCell' width='98%' height='70%' align='center' hspace='0' vspace='0' ><param name='RpCellMode' value='2'></OBJECT>")
OpenWindow.document.write("</p>")
OpenWindow.document.write("</BODY>")
OpenWindow.document.write("</HTML>")
OpenWindow.document.close()
}
function closeWindow() //关闭本窗口的函数
{
window.opener = null;
window.open('', '_self', '');
window.close();
}
</script>
</head>
<body onload="openwin();closeWindow()"> //弹出窗口后,关闭本窗口
</body>
</html>
1.OpenWindow.document.write(" ")中套嵌的标签中有引号的,一定要用单引号 ' ;
2.OpenWindow.document.write(" ")中允许套嵌多个标签,但标签外一定不能再额外地加双引号,如果加了双引号,本行代码将不能执行,并直接导致不能弹出窗口;如果加了单引号、逗号,将作为普通字串输出在网页上。