javascript当中open&close的用法
例 1.4.1(open&closeIEFF.html)
cla.html
请选择班级
0708
0709
0802
您的浏览器不支持video标签
例 1.4.2(OpenCloseWriteDocumentIEFF.html)
var n = 0;
var win = null;
function show(msg)
{
/*Window.closed (Property)
A property value that is true if the window is closed. qixy: but even though win is closed, win.closed=true, but
win does not become null, because win is this window's property, it as a property is not destroyed.
*/
msg=msg+"win is"+win;
if ((win == null) || (win.closed))
{
msg=msg+"inside if (win == null) || (win.closed)";
// alert("win is"+win);
/*aNewWindow = myWindow.open(aURL, aName, aFeatureList)
aFeatureList A list of attributes for the new window
aName The name of a new or existing target window
*/
win =window.open("","consoleqixy","width=400,height=250,resizable");
}
win.focus();
/*马克-to-win:the following two statements means: clear the document. because clear is deprecated.if you remove the following two statements, win.document still has past content. so new content appends past content. so contens becomes more and more.qixy: if window is closed, its document also is cleared.*/
// win.document.clear();
win.document.close();
win.document.open();
win.document.writeln(msg);
/*马克-to-win:the following two statements can not be used to write content, because later on the whole page content only will have the following two statement's content, so function body is also missing. to solve the problem refer to OpenCloseWriteDocument1.html, the conclusion is that when we want to write something, we open another new window to write in.*/
//document.writeln('');
// document.writeln("this "+msg);
}
您的浏览器不支持video标签
例 1.4.3(OpenCloseWriteDocument2IEFF.html)
var n = 0;
var win = null;
function show(msg)
{
/*Window.closed (Property)
A property value that is true if the window is closed.
*/
if ((win == null) || (win.closed))
{
win =window.open("","consoleqixy","width=400,height=250,resizable");
//将该文档打开成一个普通文档, 而不是一个text/html文档
win.document.open("text/plain");
win.x=9;
}
win.focus( );
win.document.writeln(msg+(++win.x));
}