Açé¢ç¨ window.open()æè
window.showModalDialog() ;æ¥å¼¹åºæ°çé¢
open()åshowModalDialogç¨æ³:
1ãwindow.open('my.htm','','width=400,height=300') ç¶çªä½ä»å¯æ´»å¨ã
2ãåºæ¬ä»ç»ï¼
ããshowModalDialog() (IE 4+ æ¯æ)
ããshowModelessDialog() (IE 5+ æ¯æ)
ããwindow.showModalDialog() æ¤æ¹æ³ç¨æ¥å建ä¸ä¸ªæ¾ç¤ºHTMLå
容ç模æ对è¯æ¡ã
ããwindow.showModelessDialog() æ¤æ¹æ³ç¨æ¥å建ä¸ä¸ªæ¾ç¤ºHTMLå
容çé模æ对è¯æ¡ã
ãã使ç¨æ¹æ³ï¼
ããvReturnValue = window.showModalDialog(sURL [, vArguments] [,sFeatures])
ããvReturnValue = window.showModelessDialog(sURL [, vArguments] [,sFeatures])
ããåæ°è¯´æï¼
ããsURL -- å¿
éåæ°ï¼ç±»åï¼å符串ãç¨æ¥æå®å¯¹è¯æ¡è¦æ¾ç¤ºçææ¡£çURLã
ããvArguments -- å¯éåæ°ï¼ç±»åï¼åä½ãç¨æ¥å对è¯æ¡ä¼ éåæ°ãä¼ éçåæ°ç±»åä¸éï¼å
æ¬æ°ç»çã对è¯æ¡éè¿window.dialogArgumentsæ¥åå¾ä¼ éè¿æ¥çåæ°ã
ããsFeatures -- å¯éåæ°ï¼ç±»åï¼å符串ãç¨æ¥æ述对è¯æ¡çå¤è§çä¿¡æ¯ï¼å¯ä»¥ä½¿ç¨ä»¥ä¸çä¸ä¸ªæå 个ï¼ç¨åå·â;âéå¼ã
----------------
1. dialogHeight: 对è¯æ¡é«åº¦ï¼ä¸å°äº100px
2. dialogWidth: 对è¯æ¡å®½åº¦ã
3. dialogLeft: 离å±å¹å·¦çè·ç¦»ã
4. dialogTop: 离å±å¹ä¸çè·ç¦»ã
5. center: { yes | no | 1 | 0 } ï¼ æ¯å¦å±
ä¸ï¼é»è®¤yesï¼ä½ä»å¯ä»¥æå®é«åº¦å宽度ã
6. help: {yes | no | 1 | 0 }ï¼ æ¯å¦æ¾ç¤ºå¸®å©æé®ï¼é»è®¤yesã
7. resizable: {yes | no | 1 | 0 } [IE5+]ï¼ æ¯å¦å¯è¢«æ¹å大å°ãé»è®¤noã
8. status:{yes | no | 1 | 0 } [IE5+]ï¼æ¯å¦æ¾ç¤ºç¶ææ ãé»è®¤ä¸ºyes[ Modeless]æno[Modal]ã
9. scroll:{ yes | no | 1 | 0 | on | off }ï¼æ¯å¦æ¾ç¤ºæ»å¨æ¡ãé»è®¤ä¸ºyesã
ä¸é¢å 个å±æ§æ¯ç¨å¨HTAä¸çï¼å¨ä¸è¬çç½é¡µä¸ä¸è¬ä¸ä½¿ç¨ã
10. dialogHide:{ yes | no | 1 | 0 | on | off }ï¼å¨æå°æè
æå°é¢è§æ¶å¯¹è¯æ¡æ¯å¦éèãé»è®¤ä¸ºnoã
11. edge:{ sunken | raised }ï¼ææ对è¯æ¡çè¾¹æ¡æ ·å¼ãé»è®¤ä¸ºraisedã
12. unadorned:{ yes | no | 1 | 0 | on | off }ï¼é»è®¤ä¸ºnoã
ããåæ°ä¼ éï¼
1.è¦æ³å¯¹è¯æ¡ä¼ éåæ°ï¼æ¯éè¿vArgumentsæ¥è¿è¡ä¼ éçãç±»åä¸éå¶ï¼å¯¹äºå符串类åï¼æ大为4096个å符ãä¹å¯ä»¥ä¼ é对象ï¼ä¾å¦ï¼
-------------------------------
parent.htm
<script>
ããvar obj = new Object();
ããobj.name="51js";
ããwindow.showModalDialog("modal.htm",obj,"dialogWidth=200px;dialogHeight=100px");
</script>
modal.htm
<script>
ããvar obj = window.dialogArguments
ããalert("æ¨ä¼ éçåæ°ä¸ºï¼" + obj.name)
</script>
-------------------------------
2. å¯ä»¥éè¿window.returnValueåæå¼å¯¹è¯æ¡ççªå£è¿åä¿¡æ¯ï¼å½ç¶ä¹å¯ä»¥æ¯å¯¹è±¡ãä¾å¦ï¼
------------------------------
parent.htm
<script>
str =window.showModalDialog("modal.htm",,"dialogWidth=200px;dialogHeight=100px");
alert(str);
</script>
modal.htm
<script>
window.returnValue="
http://www.webjx.com";
</script>