如题所述
è¿ä¸ªå¨ç½é¡µå端ä¸é常常ç¨ï¼å¦æä½ JS é¨åå¦å¥½äº è¿ä¸ªä¹æ¯é常容æçäº ä¸é¢æ¯å
·ä½çå®ç°æ¹æ³ã
ãæåºæ¬çå¼¹åºçªå£ä»£ç ãï¼å ¶å®ä»£ç é常ç®åï¼ï¼
<SCRIPTLANGUAGE="ï¼<!--ï¼window.open('page.htï¼-->ï¼</SCRIPT>ï¼å 为è¿æ¯ä¸æ®µjavascript代ç ï¼æ以å®ä»¬åºï¼Window.open('page.htï¼è¿ä¸æ®µä»£ç å¯ä»¥å å ¥HTMLçä»»æä½ç½®ï¼å å ¥å°&lï¼ã
ãæåºæ¬çå¼¹åºçªå£ä»£ç ã
å ¶å®ä»£ç é常ç®åï¼
<SCRIPT LANGUAGE="javascript"><!--
window.open ('page.html')
-->
</SCRIPT>
å 为è¿æ¯ä¸æ®µjavascript代ç ï¼æ以å®ä»¬åºè¯¥æ¾å¨<SCRIPT LANGUAGE ="javascript">æ ç¾å</script>ä¹é´ã<!--å-->æ¯å¯¹ä¸äºçæ¬ä½çæµè§å¨èµ·ä½ç¨ï¼å¨è¿äºèæµè§å¨ä¸å¦æä¸æ¯æjavascriptï¼ä¸ä¼å°æ ç¾ä¸ç代ç ä½ä¸ºææ¬æ¾ç¤ºåºæ¥ã
Window.open ('page.html')ç¨äºæ§å¶å¼¹åºæ°ççªå£page.htmlï¼å¦æpage.htmlä¸ä¸ä¸»çªå£å¨åä¸è·¯å¾ä¸ï¼åé¢åºåæè·¯å¾ï¼ç»å¯¹è·¯å¾(http://)åç¸å¯¹è·¯å¾(../)åå¯ã ç¨åå¼å·ååå¼å·é½å¯ä»¥ï¼åªæ¯ä¸è¦æ··ç¨ã
è¿ä¸æ®µä»£ç å¯ä»¥å å ¥HTMLçä»»æä½ç½®ï¼å å ¥å°<head>å</head>ä¹é´ä¹å¯ä»¥ï¼ä½ç½®è¶é åæ§è¡è¶æ©ï¼å°¤å ¶æ¯é¡µé¢ä»£ç è¾é¿æ¶ï¼åæ³ä½¿é¡µé¢æ©ç¹å¼¹åºå°±å°½éå¾åæ¾ã
ãç»è¿è®¾ç½®åçå¼¹åºçªå£ã
ä¸é¢å说ä¸è¯´å¼¹åºçªå£å¤è§ç设置ãåªè¦åå¾ä¸é¢ç代ç ä¸å ä¸ç¹ä¸è¥¿å°±å¯ä»¥äºã
æ们æ¥å®å¶è¿ä¸ªå¼¹åºçªå£çå¤è§ã尺寸大å°ãå¼¹åºä½ç½®ä»¥éåºè¯¥é¡µé¢çå ·ä½æ åµã
<SCRIPT LANGUAGE="javascript:><!--
window.open ('page.html','newwindow','height=100,width=400,top=0,left=0,
toolbar=no,menubar=no,scrollbars=no,resizable=no,
location=no,status=no')
//åæä¸è¡
-->
</SCRIPT>
åæ°è§£éï¼
<SCRIPT LANGUAGE="javascript"> jsèæ¬å¼å§ï¼
window.open å¼¹åºæ°çªå£çå½ä»¤ï¼
page.html å¼¹åºæ°çªå£çæ件åï¼
newwindow å¼¹åºçªå£çååï¼ä¸æ¯æ件åï¼ï¼å¯ç¨ç©º â³ä»£æ¿ï¼
height=100 çªå£é«åº¦ï¼
top=0 çªå£è·ç¦»å±å¹ä¸æ¹çåç´ å¼ï¼
left=0 çªå£è·ç¦»å±å¹å·¦ä¾§çåç´ å¼ï¼
toolbar=no æ¯å¦æ¾ç¤ºå·¥å ·æ ï¼yes为æ¾ç¤ºï¼
menubar,scrollbars 表示èåæ åæ»å¨æ ï¼
resizable=no æ¯å¦å 许æ¹åçªå£å¤§å°ï¼yes为å 许ï¼
location=no æ¯å¦æ¾ç¤ºå°åæ ï¼yes为å 许ï¼
status=no æ¯å¦æ¾ç¤ºç¶ææ å çä¿¡æ¯ï¼é常æ¯æ件已ç»æå¼ï¼ï¼yes为å 许ï¼
</SCRIPT> jsèæ¬ç»æã
ãç¨å½æ°æ§å¶å¼¹åºçªå£ã
ä¸é¢æ¯ä¸ä¸ªå®æ´ç代ç ã
<html><head>
<script LANGUAGE="javascript">
<!--
function openwin(){
window.open("page.html","newwindow","height=100,width=400,toolbar=no,menubar=no,scrollbars=no,resizable=no,
location=no,status=no";)
//åæä¸è¡
}
-->
</script>
</head>
<body onload="openwin()">
...ä»»æç页é¢å 容...
</body>
</html>
è¿éå®ä¹äºä¸ä¸ªå½æ°openwin(),å½æ°å 容就æ¯æå¼ä¸ä¸ªçªå£ãå¨è°ç¨å®ä¹å没æä»»ä½ç¨éãæä¹è°ç¨å¢ï¼
æ¹æ³ä¸ï¼<body onload="openwen()"> æµè§å¨è¯»é¡µé¢æ¶å¼¹åºçªå£ï¼
æ¹æ³äºï¼<body onunload="openwen()"> æµè§å¨ç¦»å¼é¡µé¢æ¶å¼¹åºçªå£ï¼
æ¹æ³ä¸ï¼ç¨ä¸ä¸ªè¿æ¥è°ç¨ï¼<a href="#" onclick="openwin()">æå¼ä¸ä¸ªçªå£</a>
注æï¼ä½¿ç¨ç"#"æ¯èè¿æ¥ã
æ¹æ³åï¼ç¨ä¸ä¸ªæé®è°ç¨ï¼<input type="button" onclick="openwin()" value="æå¼çªå£">
ã主çªå£æå¼æ件1.htmï¼åæ¶å¼¹åºå°çªå£page.htmlã
å°å¦ä¸ä»£ç å å ¥ä¸»çªå£<head>åºï¼
<script language="javascript"><!--
function openwin(){
window.open("page.html","","width=200,height=200" ;)
}
//-->
</script>
å å ¥<body>åºï¼
<a href="http://www.xsteach.com/register?spread_id=6065805" onclick="openwin()">open</a>å³å¯ã
ãå¼¹åºççªå£ä¹å®æ¶å ³éæ§å¶ã
ä¸é¢æ们å对弹åºçªå£è¿è¡ä¸äºæ§å¶ï¼ææå°±æ´å¥½äºãå¦ææ们åå°ä¸å°æ®µä»£ç å å ¥å¼¹åºç页é¢ï¼æ³¨ææ¯å å ¥å°page.htmlçHTMLä¸ï¼å¯ä¸æ¯ä¸»é¡µé¢ä¸ï¼å¦åâ¦ï¼ï¼è®©å®å¨10ç§éåèªå¨å ³éæ¯ä¸æ¯æ´é ·äºï¼
é¦å ï¼å°å¦ä¸ä»£ç å å ¥page.htmlæ件ç<head>åºï¼
<script language="javascript">function closeit() {
setTimeout("self.close()",10000) //毫ç§
}
</script>
ç¶åï¼åç¨<body onload="closeit()">è¿ä¸å¥è¯ä»£æ¿page.htmlä¸åæç<BODY>è¿ä¸å¥å°±å¯ä»¥äºãï¼è¿ä¸å¥è¯åä¸ä¸è¦å¿è®°ååï¼è¿ä¸å¥çä½ç¨æ¯è°ç¨å ³éçªå£ç代ç ï¼10ç§éåå°±èªè¡å ³é该çªå£ãï¼
ãå¨å¼¹åºçªå£ä¸å ä¸ä¸ä¸ªå ³éæé®ã
<form><INPUT TYPE='BUTTON' value='å ³é' onClick='window.close()'>
</form>
åµåµï¼ç°å¨æ´å å®ç¾äºï¼
åæ¥çHTMLæ åä¸å¯ä»¥ç¨
<a href="document.html" target="_blank"> æå¼ä¸ä¸ªæ°çªå£</a>
ä½æ°çHTMLæ åä¸¥æ ¼ä¸æ¯ä¸å 许çãå¯ä»¥éç¨ä»¥ä¸ä»£ç ï¼
<a href="document.html" rel="external">æå¼ä¸ä¸ªæ°çªå£</a>javascript:
function externallinks() {
if (!document.getElementsByTagName) return;
var anchors = document.getElementsByTagName("a");
for (var i=0; i<anchors.length; i++) {
var anchor = anchors[i];
if (anchor.getAttribute("href") &&
anchor.getAttribute("rel") == "external")
anchor.target = "_blank";
}
}
window.onload = externallinks;
æ们å¨ä½¿ç¨<a>æ ç¾æ¶ï¼å¸¸å¸¸ä¼ä½¿ç¨å®çhrefå±æ§ä¸º ä¸æ®µjavasrciptæ¥å®ç°æäºåè½ãæ¯å¦å
³éä¸ä¸ªçªå£ï¼<a href="javascript:windows.close();">ï¼æè
å¼¹åºä¸ä¸ªæ°ççªå£<a href="javascript:windows.open('url');">ãè¿æ ·æ¥å®ç°çªå£çæä½ã
å½ç¶ä¹æ人ä¼ç¨ onclickäºä»¶æ¥å®ç°æå¼æè å ³éçªå£<a href="#" onclick="windows.close();">, æå¼æ°çªå£<a href="#" onclick="windows.open(url);">ãé£ä¹ä»ä»¬ä¹é´å°åºæä»ä¹åºå«å¢ï¼ä¸é¢æ¥å¥½å¥½åæä¸ä¸
<a href="javascript:windows.close();">å ³éçªå£æ¶ï¼æµè§å¨ä¸ä¼å¼¹åºçªå£å ³éç对è¯æ¡ï¼è<a href="#" onclick="windows.close();">,æµè§å¨å°±ä¼å¼¹åºçªå£å ³éç对è¯æ¡ã
<a href="javascript:windows.open('url');">æå¼ä¸ä¸ªæ°ççªå£æ¶ï¼ä¼ä½¿åæ¥ççªå£åç页é¢åä¼ ï¼ä»èå¯¼è´ cssæ ·å¼æ æï¼å¦ææ¯å¨æ页é¢çè¯è¿å¯è½å¯¼è´é¡µé¢å空ç½ãæ以è¿æ¯æ ç¨è¿ä¸ªæ¹æ³ã<a href="#"
onclick="windows.close();">,æ¯å®å ¨å¨å®¢æ·ç«¯æ§è¡çå¨ä½ï¼é¡µé¢ä¸ä¼äº§çåä¼ ï¼ä¸ä¼å·æ°é¡µé¢ã
<li onclick="javascript:window.open
('é¾æ¥')"> </li>
<html>
<body>
<a href="../asdocs/html_tutorials/humor01.html" target="_blank">*****</a>
<p>
你点击这个链接的时候,网页就会在一个新窗口出现。
</p>
</body>
</html>本回答被网友采纳