JavaScript ¶¯»
ÎÒÃÇ¿ÉÒÔʹÓà JavaScript À´´´½¨¶¯Ì¬µÄͼÏñ¡£
ʵÀý
°´Å¥¶¯»
ÀûÓÃÁ½¸ö²»Í¬µÄʼþÀ´Çý¶¯Á½¸öÏàÓ¦µÄº¯Êý£¬À´Çл»Á½ÕŶÔÓ¦µÄͼƬÒÔ´´Ôì³ö¶¯»Ð§¹û¡£
JavaScript ¶¯»
ʹÓà JavaScript ´´½¨¶¯Ì¬Í¼ÏñÊÇ¿ÉÐеġ£
ÇÏÃÅ
ÊÇ£ºÊ¹Óà JavaScript ͨ¹ý²»Í¬µÄʼþÀ´Çл»²»Í¬µÄͼÏñ¡£
ÔÚÏÂÃæµÄÀý×ÓÖУ¬ÎÒÃÇÒªÖÆ×÷Ò»¸ö³äµ±Á´½Ó°´Å¥µÄͼÏñ¡£ÎÒÃǽ«Ê¹Óà onMouseOver ʼþºÍ onMouseOut ʼþÀ´Çý¶¯ JavaScript º¯ÊýÇл»Í¼Ïñ¡£
HTML ´úÂë
ÕâÊÇ HTML ´úÂ룺
<a href="http://www.w3school.com.cn" target="_blank">
<img border="0" alt="Visit W3School!"
src="/i/eg_mouse2.jpg" name="b1"
onmouseOver="mouseOver()"
onmouseOut="mouseOut()" />
</a>
×¢Òâ
£ºÎÒÃÇÒÑΪͼÏñÌí¼ÓÁË name ÊôÐÔ£¬ÕâÑù JavaScript ¾ÍÄÜÕÒµ½ËüÁË¡£
onMouseOver ʼþµÄ×÷ÓÃÊǸæÖªä¯ÀÀÆ÷£ºÒ»µ©Êó±êÐü¸¡ÓÚͼÏñÖ®ÉÏ£¬ä¯ÀÀÆ÷¾Í»áÖ´ÐÐij¸öº¯Êý£¬Õâ¸öº¯Êý»á°ÑÕ⸱ͼÏñÌ滻ΪÁíÒ»·ù¡£
onMouseOut ʼþµÄ×÷ÓÃÊǸæÖªä¯ÀÀÆ÷£ºÒ»µ©Êó±êÀ뿪ͼÏñ£¬ä¯ÀÀÆ÷¾ÍÒªÖ´ÐÐÁíÒ»¸öº¯Êý£¬Õâ¸öº¯Êý»áÖØвåÈëÔÀ´µÄÄÇ·ùͼÏñ¡£
JavaScript ´úÂë
ͨ¹ýÏÂÃæµÄ´úÂëÀ´Çл»Í¼Ïñ£º
<script type="text/javascript">
function mouseOver()
{
document.b1.src ="/i/eg_mouse.jpg"
}
function mouseOut()
{
document.b1.src ="/i/eg_mouse2.jpg"
}
</script>
º¯Êý mouseOver() ½«Í¼ÏñÇл»Îª "eg_mouse.jpg"¡£
º¯Êý mouseOut() ½«Í¼ÏñÇл»Îª "eg_mouse2.jpg"¡£
ÍêÕûµÄ´úÂ룺
<html>
<head>
<script type="text/javascript">
function mouseOver()
{
document.b1.src ="/i/eg_mouse.jpg
"
}
function mouseOut()
{
document.b1.src ="/i/eg_mouse2.jpg
"
}
</script>
</head>
<body>
<a href="http://www.w3school.com.cn" target="_blank">
<img border="0" alt="Visit W3School!" src="/i/eg_mouse2.jpg" name="b1"
onmouseOver="mouseOver()"
onmouseOut="mouseOut()"
/>
</a>
</body>
</h
Ïà¹ØÎĵµ£º
ðÅÝÐÍʼþ ʼþ·¢ÉúÓÉÄÚ¶øÍâ
¿ÉÒÔ¶Ôʱ¼ä´«µÝº¯ÊýÒÔÓ¦¶Ô¶¯×÷µÄ´Ù·¢
oP.attachEvent("onclick",fnClick); ¶Ô¶ÔÏóÔö¼ÓÒ»¸ö¼àÌýº¯Êý£¬Í¬Ò»¸ö¶ÔÏó¿ÉÒÔ¼àÌýÏàͬʼþ¶ÔÓ¦²»Í¬µÄʼþ´¦Àíº¯Êý Ö´ÐÐ˳ÐòºóÓÅÏÈ oP.detachEvent("onclick",fnClick);ɾ³ý¼àÌý ÊʺÏÓÃÓ ......
ÔÚjsÀïÓõ½Êý×é,±ÈÈç ¶à¸öÃû×ÖÏàͬµÄinput, ÈôÊǶ¯Ì¬Éú³ÉµÄ, Ìύʱ¾ÍÐèÒªÅжÏÆäÊÇ·ñÊÇÊý×é.
if(document.mylist.length != "undefined" ) {} Õâ¸öÓ÷¨ÓÐÎó.
ÕýÈ·µÄÊÇ if( typeof(document.mylist.length) != "undefined" ) {}
»ò if( !isNaN(document.mylist.length) ) {}
typeofµÄÔËËãÊý䶨Òå,·µ»ØµÄ¾ÍÊÇ "un ......
JavascriptÖÐ×î³£ÓõÄ55¸ö¾µä¼¼ÇÉ ÊÕ²Ø
1. oncontextmenu="window.event.returnValue=false" ½«³¹µ×ÆÁ±ÎÊó±êÓÒ¼ü
<table border oncontextmenu=return(false)><td>no</table> ¿ÉÓÃÓÚTable
2. <body onselectstart="return false"> È¡ÏûÑ¡È¡¡¢·ÀÖ¹¸´ÖÆ
3. onpaste="return false" ²»×¼Õ³Ìù
4 ......
1. oncontextmenu="window.event.returnValue=false" ½«³¹µ×ÆÁ±ÎÊó±êÓÒ¼ü
<table border oncontextmenu=return(false)><td>no</table> ¿ÉÓÃÓÚTable
2. <body onselectstart="return false"> È¡ÏûÑ¡È¡¡¢·ÀÖ¹¸´ÖÆ
3. onpaste="return false" ²»×¼Õ³Ìù
4. oncopy="return false;" oncut="re ......
function sAlert(msg,boxtype,func,msgtitle)
sAlert('ÐÅÏ¢ÄÚÈÝ',1,'','ÐÅÏ¢±êÌâ')
@msg:ÌáʾÐÅÏ¢ÄÚÈÝ
@boxtype£º1Ϊµ¯³ö¿ò£¬2ΪȷÈÏ¿ò£¬3ΪÌáʾ¿ò
@func:µãÈ·ÈÏʱִÐеĺ¯Êý
@title:ÐÅÏ¢¿ò±êÌâÎÄ×ÖÄÚÈÝ
Ö»ÓÐmsgÊDZØÐëµÄ£¬ºóÃæµÄ²ÎÊý¿ÉÒÔÊ¡ÂÔ¡£Èç¹ûÖмäµÄ²ÎÊýΪ¿ÕÔòÔÚ¶ÔӦλÖÃÉÏ''»òÕß""±íʾ£¨¸ù¾Ýʵ¼ÊÇé¿öÑ¡Ôñµ ......