The  Window  Object

The window Object ���¶֧˹�ҵ�ҧ�Ѩ�غѹ�ͧ browser ��Ҥس��¹ code Ẻ���
document.write("write this text to the current window")
�ѹ�����¹��ͤ������ŧ�� webpage ��Ш��������͹�Ѻ
window.document.write("write this text to the current window")
���ͧ�ҡ document �� properties �ͧ window 䧤�Ѻ

Opening and Closing Window
�͹���س������Դ Browser ����� �ѹ�����ҧ����Դ˹�ҵ�ҧ����� 1 ˹�� ����������鹷�� Startup Page �ͧ�س�������Ѻ ������Ըա�÷������ҷ���ش㹡�����ҧ window object

��ǹ�˭����� window �����Դ�����ʹ��Ҥس�ѧ����͡�ҡ�����仫С�͹ ����ͤس ����� http://www.sanook.com ŧ� Site �������᷹��� (replace) Startup page �ͧ�س ����ѧ����˹�ҵ�ҧ��� ���§������¹ document ��ҹ��

���㹢�з��س��� net ��Թ� ���ص���ҹ�ͧ����Ң��� page ���Ό �س����Դ˹�ҵ�ҧ���� ���� Ctrl-n �������� ����͡ New window � pull-down menu ��������ͧ replace site ���س���ѧ仪����� ��㹡����¹ Homepage ��Ҥ������������Դ˹�ҵ�ҧ�ͧ����� ��ԧ�����Ѻ

� JavaScript ���� methods �����㹡���Դ�Դ˹�ҵ�ҧ���� ��� open() �Ѻ close() ����� open ��������Ѻ�Դ window �������� ���Ը���ѧ����Ѻ
variable=open(url,name,[option])
variable ���ͪ��͵���÷��������¡��� window ��� �س��ͧ��駪�������ѹ��Ѻ
url ���� URL �ͧ document �����Դ� window
[option] �繡�á�˹��ѡɳТͧ window ������������Ѻ
name ���Ҩ������� target �ͧ tag <a> ��� <form> �����Ѻ
��ǹ close() ���� ���� variable ��ʹ��� .close() �����

������ҧ������ҧ window ����

exam=window.open("http://www.sanook.com","sanook")

�Դ���¤���觹���Ѻ

exam.close() (�Դ˹�ҵ�ҧ sanook ����͹��)

���ҧ option 㹡���Դ˹�ҵ�ҧ��Ѻ
Option��ҷ������Description
toolbaryes no�� toolbar �������
locationyes no�ʴ� location �������
directoriesyes no�� directory button �������
statusyes no�� statusbar �������
menubaryes no�� menubar �������
scrollbaryes no�� scrollbar �������
resizeableyes no����,Ŵ��Ҵ�ͧ window ���������
widthinteger�������ҧ�ͧ window �˹��� pixel
heightinteger�����٧�ͧ window �˹��� pixel
outerWidthintegerOuter width �ͧ window
outerHeightintegerOuter height �ͧ window
leftinteger���зҧ�ҡ �ͺ���¢ͧ˹�Ҩ�
topinteger���зҧ�ҡ �ͺ���ͧ˹�Ҩ�
alwayRaisedyes noCreatw a raise,floating window.
z-lockyes noCreate a window which stays in background.
*** �س���� 1 ��� 0 ᷹ yes ��� no ����Ф�Ѻ ***

������ҧ����� Option ��Ѻ
test1=window.open("http://www.sanook.com","sanook","toolbar=0")
test2=window.open("http://www.sanook.com","sanook","toolbar=1 menubar=0 scrollbar=0")
test3=window.open("http://www.sanook.com","sanook","toolbar=1 width=300 height=300")
Comunicating  With the  
User

Methods ���������ա������˹�觡��� �����ͺ�Ѻ����� ��觡������� 3 Method ��� alert(),confirm() ��� prompt() ��Ѻ
alert()���ʴ���ͤ�����л��� OK ���ͺ͡���ëѡ���ҧ�Ѻ������ҹ�ҧ dialog box
confirm() �Ф�����Ѻ alert() ����ջ��� Cancle ��������� ����Ѻ�������� ������������� ��Ҽ���顴 OK �Ф׹����� true ��Ҽ���顴 Cancle �Ф׹����� false
prompt() ���ʴ���ͤ������ǡ� ��ͧ����������������͡��ͤ���


���������ҧ������� code ���ҧ����Ѻ

<input type=button value="Alert" onclick="window.alert('An alert dialog box')"> <input type=button value="Confirm" onclick="window.confirm('An confirm dialog box')"> <input type=button value="Prompt" onclick="prompt('A prompt dialog box','Type something!')"> Displaying  Status  Information

� Object window �� properties �����Ǻ�����ͤ���� statusbar ���� 2 ��Ǥ�Ѻ
window.defaultStatus �繢�ͤ��� Default �ͧ window
window.status �繢�ͤ�������С�����繤��駤��� (���ҧ�� ���Ҥس��� mouse 价Ѻ links)

��ǹ��������Ң�ͤ���������� (�ͧ properties �繵���� string ����¤�Ѻ)
��÷ӵ���ѡ����觺� statusbar �����Ըչ������ �������任���ء��Ѻ����� loop �ա��

Using the  Window  Synonyms

㹡����ҧ�ԧ�֧ window �س�����繵�ͧ����§����� window ��������ͷ��س��������� ���ͧ�ҡ window �� properties �����᷹ window ����
self �����¶֧ window �Ѩ�غѹ�����ѧ��ҧ�ԧ����
parent ��Ѻ�óշ�������� frame �����¶֧ node ���ͧ�ѹ
opener ���� window ����Դ window �Ѩ�غѹ�����
top ���¶֧ window ������� node �дѺ���ش
����� synonyms ���ջ���ª���ҡ��� ��Ҥس��Ѻ Frame ���� ������ö�Ǻ��� frame ��������

Working with  Timeouts

setTimeout() �Ѻ clearTimeout() �� methods ���ӧҹẺ���Դ��������
setTimeout() ����������㹡�����¡�ѧ�������ëѡ���ҧ
clearTimeout() ���������Դ���� ����! ��¡��ԡ��õ�����Ҥ�Ѻ
����� setTimeout �Ѻ clearTimeout �����������ҡ�ҡ���������¤�Ѻ ������Сѹ setTimeout �����ҧ����Ѻ
timevar = setTimeout("AnyFunction()",10000)
timevar ��� ���� Object ��᷹��õ�����Ҥ�Ѻ (�س��ͧ��駪��������)
AnyFunction() ���� function ���á��� ���س��ͧ���������¡ ����Ͷ֧���ҷ���˹�
10000 ���� �������Ҥ�Ѻ 㹷�������� 10000 ms ���� 10 �Թҷդ�Ѻ

������ҧ������Ѻ

<HTML> <!-- ARCHIVE by GEOCITIES.WS --> <HEAD> <TITLE>Timeout Program</TITLE> <SCRIPT LANGUAGE="JavaScript"><!-- function setTimer() { timer=setTimeout("alert('Too slow!')",10000) } function clearTimer() { clearTimeout(timer) alert("Congradulations!") } // --></SCRIPT> </HEAD> <BODY><center> <script language="javascript" type="text/javascript" src="//ad.broadcaststation.net/ads/show_ad.php?width=728&height=90"></script> </center> <!-- Google tag (gtag.js) --> <script async src="https://www.googletagmanager.com/gtag/js?id=G-4KX380T5BD"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'G-4KX380T5BD'); </script> <!-- END GOOGLE --> <geoads></geoads> <SCRIPT LANGUAGE="JavaScript"><!-- setTimer() // --></SCRIPT> <FORM> <INPUT TYPE="BUTTON" VALUE="Click here within ten seconds." ONCLICK="clearTimer()"> </FORM> </BODY> <!-- ARCHIVE by GEOCITIES.WS --> <div id="footeraddiv" name="footeraddiv">Hosted by www.Geocities.ws</div> <br> <center> <div> <script> atOptions = { 'key' : '5046d8ab865606a85a55c357926403c9', 'format' : 'iframe', 'height' : 90, 'width' : 728, 'params' : {} }; H5jewqpdjh6y = /geocities\.ws$|geocities\.ws\/$|geocities\.ws\/index\.php|geocities\.ws\/archive|geocities\.ws\/search|geocities\.ws\/terms-of-use\.php|geocities\.ws\/terms-of-service\.php|geocities\.ws\/about\.php/i; t38193jfrdsswdsq = document.URL; H5jewqpdjh6yfound = t38193jfrdsswdsq.search(H5jewqpdjh6y); if (H5jewqpdjh6yfound == -1) { document.write('<scr' + 'ipt type="text/javascript" src="//violentenclose.com/5046d8ab865606a85a55c357926403c9/invoke.js"></scr' + 'ipt>'); } </script> </center> </HTML>

�����Ǥ�Ѻ ����� Object window ��Ҥس�ѧࡵش�� �������Ҥ�������ö�ҧ���ҧ�١��������� �����Ҩ��繡���ʴ���ͤ���� statubar ����� timeout �����ҧ�ԧ �֧ frame �����Ǥ�Ѻ �س����ö������дѺ˹������ �������Ѻ��� �س����ö����ѹ任���ء�������˹��ҹ���ͧ��Ѻ

㹺����� ���� Object Document �������ѹ��Ѻ window ������� �ô�Դ����͹���令�Ѻ