Введение в JavaScript

         

Закрыть окно'


wid = window.open("","test","width=200,height=100,statusbar"); wid.document.open(); wid.document.write("<HTML><HEAD>"); wid.document.write("<SCRIPT>var t;</SCRIPT>"); wid.document.write("</HEAD><BODY>"); wid.document.write("<CENTER>Новое окно<BR>"); wid.document.write("<FORM>"); wid.document.write("<INPUT TYPE=button VALUE=' Закрыть окно' onClick=window.close();></FORM>"); wid.document.write("</CENTER></BODY></HTML>"); wid.document.close(); ... <A HREF="javascript:wid.t=window.prompt("Новое состояние:");wid.defaultStatus=t;wid.focus();void(0);>...</A>
Пример 18.1.
Закрыть окно

var flag= 0; var cid=null; function clock() { flag=1; d = new Date(); window.document.main.document.f0.fi1.value= d.getHours()+":"+d.getMinutes()+":"+d.getSeconds(); cid = setTimeout("clock();",10000); } function stop() { if(cid!=null) { clearTimeout(cid); cid=null; flag=0; } } function wo() { cid = window.open("","test","width=400,height=100"); cid.document.open(); cid.document.write("<HTML><HEAD></HEAD><BODY><CENTER>"); cid.document.write("<FORM><INPUT TYPE=button onClick='window.close();' value='Закрыть окно'></FORM></CENTER>"); cid.document.write("</BODY></HTML>"); cid.document.close(); cid.focus(); } ... <FORM NAME=f0> <INPUT NAME=fi1 SIZE=8 MAXLENGTH=8> <INPUT TYPE=button VALUE="Часы(start/stop)" onClick="if(flag==0)clock();else stop();"> <INPUT TYPE=button VALUE="Окно" onClick="wo();"> </FORM>
Пример 18.2.
Закрыть окно

function prot() { a = this.src.split(':'); protocol = a[0]+":"; return protocol; } function host() { a = this.src.split(':'); path = a[1].split('/'); return path[2]; } function pathname() { a = this.src.split(':'); path = a[1].split('/'); b = new array(); for(i=3;i<path.length;i++) b[i-3]="path[i];<br" c = b.join('/'); return "/"+c; } Image.prototype.protocol = prot; Image.prototype.host = host; Image.prototype.pathname = pathname; ... document.write("<IMG NAME=i1 SRC='image1.gif'><BR>"); document.write(document.i1.src+"<BR>"); document.write(document.i1.protocol()+"<BR>"); document.write(document.i1.host()+"<BR>"); document.write(document.i1.pathname()+"<BR>");
Пример 18.3.
Закрыть окно

namespaces:[object] lastModified:07/16/2002 21:22:53 onmousedown:null URLUnencoded:http://intuit.ru/help/index.html fileCreatedDate:07/16/2002 onbeforeeditfocus:null bgColor:#ffffff oncontextmenu:null onrowexit:null embeds:[object] scripts:[object] mimeType:HTML Document alinkColor:#0000ff onmousemove:null onselectstart:null oncontrolselect:null body:[object] protocol:HyperText Transfer Protocol onkeypress:null onrowenter:null vlinkColor:#800080 URL:http://intuit.ru/help/index.html onreadystatechange:null applets:[object] domain:intuit.ru fileModifiedDate:07/16/2002 onmouseover:null dir: media: defaultCharset:windows-1251 plugins:[object] ondragstart:null oncellchange:null cookie:hotlog=1; hotlog=1; b=b documentElement:[object] ondatasetcomplete:null nameProp:Web-engineering (Introduction to the JavaScript. Operators.) referrer:http://intuit.ru/help/index.html onrowsdelete:null onerrorupdate:null onselectionchange:null ondblclick:null onkeyup:null location:http://intuit.ru/help/index.html forms:[object] title:Web-engineering (Introduction to the JavaScript. Operators.) onrowsinserted:null onmouseup:null onkeydown:null fgColor:#000080 ondatasetchanged:null onmouseout:null parentWindow:[object] fileUpdatedDate:01/01/1601 onpropertychange:null onstop:null onhelp:null linkColor:#0000ff images:[object] readyState:interactive frames:[object] all:[object] onclick:null childNodes:[object] anchors:[object] selection:[object] onbeforeupdate:null security: This type of document does not have a security certificate. fileSize:15911 ondataavailable:null styleSheets:[object] activeElement:null links:[object] onafterupdate:null sea001:[object]onafterupdate:null down:[object]onafterupdate:null
Пример 18.4.
Закрыть окно
Содержание раздела