您的位置:首页 > 运维架构

用window.open方法打开新窗口显示提示信息

2006-12-05 18:13 781 查看
有时候我们需要打开一个新窗口用来显示提示信息
这个自然会想到用window.open()方法
但新窗体的内容并不是固定的
如果我们建立一个 tip.html 的静态页面,专门用来让window.open打开,打开之后再用js设置窗体的内容
这样做也能满足要求,但是有没有更好的方法呢?
下面的方法可以不用建一个专门的静态页面,而是每次都是打开一个临时窗口,窗体的内容也是动态构造的
请看代码:

<input type=button value=open onclick="openWindow=window.open();
openWindow.document.writeln('<html>');
openWindow.document.writeln('<TITLE>Open Test</TITLE>');
openWindow.document.writeln('<BODY>');
openWindow.document.writeln('<center>');
openWindow.document.writeln('Hello! New window opened!');
openWindow.document.writeln('<br><br>');
openWindow.document.writeln('<input type=button value=close onclick=window.close()>');
openWindow.document.writeln('</center>');
openWindow.document.writeln('</BODY>');
openWindow.document.writeln('</HTML>');
openWindow.document.close(); " >

function runEx() {
openWindow=window.open();
openWindow.document.writeln("');");
openWindow.document.writeln("openWindow.document.writeln('Open Test');");
openWindow.document.writeln("openWindow.document.writeln('');");
openWindow.document.writeln("openWindow.document.writeln('');");
openWindow.document.writeln("openWindow.document.writeln('Hello! New window opened!');");
openWindow.document.writeln("openWindow.document.writeln('

');");
openWindow.document.writeln("openWindow.document.writeln('');");
openWindow.document.writeln("openWindow.document.writeln('');");
openWindow.document.writeln("openWindow.document.writeln('');");
openWindow.document.writeln("openWindow.document.writeln('');");
openWindow.document.writeln("openWindow.document.close();\" >");

openWindow.document.close();
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: