1.javascript:window.open
javascript:window.open
ã1ãæåºæ¬çå¼¹åºçªå£ä»£ç ã
<SCRIPT LANGUAGE="javascript">
<!--
window.open ('page.html')
-->
</SCRIPT>
å 为çæ¯ä¸æ®µjavascripts代ç ï¼æ以å®ä»¬åºè¯¥æ¾å¨<SCRIPT LANGUAGE="javascript">æ ç¾å</script>ä¹é´ã<!-- å -->æ¯å¯¹ä¸äºçæ¬ä½çæµè§å¨èµ·ä½ç¨ï¼å¨è¿äºèæµè§å¨ä¸ä¸ä¼å°æ ç¾ä¸ç代ç ä½ä¸ºææ¬æ¾ç¤ºåºæ¥ãè¦å »æè¿ä¸ªå¥½ä¹ æ¯åãwindow.open ('page.html') ç¨äºæ§å¶å¼¹åºæ°ççªå£page.htmlï¼å¦æpage.htmlä¸ä¸ä¸»çªå£å¨åä¸è·¯å¾ä¸ï¼åé¢åºåæè·¯å¾ï¼ç»å¯¹è·¯å¾(http://)åç¸å¯¹è·¯å¾(../)åå¯ãç¨åå¼å·ååå¼å·é½å¯ä»¥ï¼åªæ¯ä¸è¦æ··ç¨ãè¿ä¸æ®µä»£ç å¯ä»¥å å ¥HTMLçä»»æä½ç½®ï¼<head>å</head>ä¹é´å¯ä»¥ï¼<body>é´</body>ä¹å¯ä»¥ï¼è¶åè¶æ©æ§è¡ï¼å°¤å ¶æ¯é¡µé¢ä»£ç é¿ï¼åæ³ä½¿é¡µé¢æ©ç¹å¼¹åºå°±å°½éå¾åæ¾ã
ã2ãç»è¿è®¾ç½®åçå¼¹åºçªå£ã
ä¸é¢å说ä¸è¯´å¼¹åºçªå£ç设置ãåªè¦åå¾ä¸é¢ç代ç ä¸å ä¸ç¹ä¸è¥¿å°±å¯ä»¥äºã æ们æ¥å®å¶è¿ä¸ªå¼¹åºççªå£çå¤è§ï¼å°ºå¯¸å¤§å°ï¼å¼¹åºçä½ç½®ä»¥éåºè¯¥é¡µé¢çå ·ä½æ åµã
<SCRIPT LANGUAGE="javascript">
<!--
window.open ('page.html', 'newwindow', 'height=, width=, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=n o, status=no') //è¿å¥è¦åæä¸è¡
-->
</SCRIPT>
åæ°è§£éï¼
<SCRIPT LANGUAGE="javascript"> jsèæ¬å¼å§ï¼
window.open å¼¹åºæ°çªå£çå½ä»¤ï¼
'page.html' å¼¹åºçªå£çæ件åï¼
'newwindow' å¼¹åºçªå£çååï¼ä¸æ¯æ件åï¼ï¼éå¿ é¡»ï¼å¯ç¨ç©º''代æ¿ï¼
height= çªå£é«åº¦ï¼
width= çªå£å®½åº¦ï¼
top=0 çªå£è·ç¦»å±å¹ä¸æ¹çè±¡ç´ å¼ï¼
left=0 çªå£è·ç¦»å±å¹å·¦ä¾§çè±¡ç´ å¼ï¼
toolbar=no æ¯å¦æ¾ç¤ºå·¥å ·æ ï¼yes为æ¾ç¤ºï¼
menubarï¼scrollbars 表示èåæ åæ»å¨æ ã
resizable=no æ¯å¦å 许æ¹åçªå£å¤§å°ï¼yes为å 许ï¼
location=no æ¯å¦æ¾ç¤ºå°åæ ï¼yes为å 许ï¼
status=no æ¯å¦æ¾ç¤ºç¶ææ å çä¿¡æ¯ï¼é常æ¯æ件已ç»æå¼ï¼ï¼yes为å 许ï¼
</SCRIPT> jsèæ¬ç»æ
ã3ãç¨å½æ°æ§å¶å¼¹åºçªå£ã
ä¸é¢æ¯ä¸ä¸ªå®æ´ç代ç ã
<html>
<head>
<script LANGUAGE="JavaScript">
<!--
function openwin() {
window.open ("page.html", "newwindow", "height=, width=, toolbar =no, menubar=no, scrollbars=no, resizable=no, location=no, status=no") //åæä¸è¡
}
//-->
</script>
</head>
<body onload="openwin()">
ä»»æç页é¢å 容...
</body>
</html>
è¿éå®ä¹äºä¸ä¸ªå½æ°openwin(),å½æ°å 容就æ¯æå¼ä¸ä¸ªçªå£ãå¨è°ç¨å®ä¹å没æä»»ä½ç¨éãæä¹è°ç¨å¢ï¼
æ¹æ³ä¸ï¼<body onload="openwin()"> æµè§å¨è¯»é¡µé¢æ¶å¼¹åºçªå£ï¼
æ¹æ³äºï¼<body onunload="openwin()"> æµè§å¨ç¦»å¼é¡µé¢æ¶å¼¹åºçªå£ï¼
æ¹æ³ä¸ï¼ç¨ä¸ä¸ªè¿æ¥è°ç¨ï¼
<a href="#" onclick="openwin()">æå¼ä¸ä¸ªçªå£</a>
注æï¼ä½¿ç¨çâ#âæ¯èè¿æ¥ã
æ¹æ³åï¼ç¨ä¸ä¸ªæé®è°ç¨ï¼
<input type="button" onclick="openwin()" value="æå¼çªå£">
ã4ãåæ¶å¼¹åº2个çªå£ã
对æºä»£ç ç¨å¾®æ¹å¨ä¸ä¸ï¼
<script LANGUAGE="JavaScript">
<!--
function openwin() {
window.open ("page.html", "newwindow", "height=, width=, top=0, left=0,toolbar=no, menubar=no, scrollbars=no, resizable=no, location=n o, status=no")//åæä¸è¡
window.open ("page2.html", "newwindow2", "height=, width=, top=1 , left=,toolbar=no, menubar=no, scrollbars=no, resizable=no, loca tion=no, status=no")//åæä¸è¡
}
//-->
</script>
为é¿å å¼¹åºç2个çªå£è¦çï¼ç¨topåleftæ§å¶ä¸ä¸å¼¹åºçä½ç½®ä¸è¦ç¸äºè¦çå³å¯ ãæåç¨ä¸é¢è¯´è¿çåç§æ¹æ³è°ç¨å³å¯ã
注æï¼2个çªå£çname(newwindowsånewwindow2)ä¸è¦ç¸åï¼æè å¹²èå ¨é¨ä¸ºç©ºã
ã5ã主çªå£æå¼æ件1.htmï¼åæ¶å¼¹åºå°çªå£page.htmlã
å¦ä¸ä»£ç å å ¥ä¸»çªå£<head>åºï¼
<script language="javascript">
<!--
function openwin() {
window.open("page.html","","width=,height=")
}
//-->
</script>
å å ¥<body>åºï¼
<a href="1.htm" onclick="openwin()">open</a>å³å¯ã
ã6ãå¼¹åºççªå£ä¹å®æ¶å ³éæ§å¶ã
ä¸é¢æ们å对弹åºççªå£è¿è¡ä¸äºæ§å¶ï¼ææå°±æ´å¥½äºãå¦ææ们åå°ä¸å°æ®µ 代ç å å ¥å¼¹åºç页é¢(注ææ¯å å ¥page.htmlçHTMLä¸ï¼å¯ä¸æ¯ä¸»é¡µé¢ä¸ï¼å¦å ...)ï¼è®©å®ç§åèªå¨å ³éæ¯ä¸æ¯æ´é ·äºï¼
é¦å ï¼å°å¦ä¸ä»£ç å å ¥page.htmlæ件ç<head>åºï¼
<script language="JavaScript">
function closeit()
{
setTimeout("self.close()",) //毫ç§
}
</script>
ç¶åï¼åç¨<body onload="closeit()"> è¿ä¸å¥è¯ä»£æ¿page.htmlä¸åæç<BODY>è¿ä¸å¥å°±å¯ä»¥äºã(è¿ä¸å¥è¯åä¸ä¸è¦å¿è®°ååï¼è¿ä¸å¥çä½ç¨æ¯è°ç¨å ³éçª å£ç代ç ï¼ç§éåå°±èªè¡å ³é该çªå£ã)
ã7ãå¨å¼¹åºçªå£ä¸å ä¸ä¸ä¸ªå ³éæé®ã
<FORM>
<INPUT TYPE='BUTTON' VALUE='å ³é' ){
openwin()
document.cookie="popped=yes"
}
}
</script>
ç¶åï¼ç¨<body onload="loadpopup()">ï¼æ³¨æä¸æ¯openwinèæ¯loadpopåï¼ï¼æ¿æ¢ä¸»é¡µé¢ä¸åæç<BODY>è¿ä¸å¥å³å¯ãä½ å¯ä»¥è¯çå·æ°ä¸ä¸è¿ä¸ªé¡µé¢æéæ°è¿ å ¥è¯¥é¡µé¢ï¼çªå£åä¹ä¸ä¼å¼¹åºäºãçæ£çPop-Only-Onceï¼
åå°è¿éå¼¹åºçªå£çå¶ä½ååºç¨æå·§åºæ¬ä¸ç®æ¯å®æäº!