Javascript »ñÈ¡Ò³ÃæÉÏÑ¡ÖеÄÎÄ×Ö
IE¿ÉÒÔµ÷Óãº
<script type="text/javascript">
// ˵Ã÷£º»ñÈ¡Ò³ÃæÉÏÑ¡ÖеÄÎÄ×Ö
// ÕûÀí£ºhttp://www.CodeBit.cn
function getSelectedText() {
if (window.getSelection) {
// This technique is the most likely to be standardized.
// getSelection() returns a Selection object, which we do not document.
return window.getSelection().toString();
}
else if (document.getSelection) {
// This is an older, simpler technique that returns a string
return document.getSelection();
}
else if (document.selection) {
// This is the IE-specific technique.
// We do not document the IE selection property or TextRange objects.
return document.selection.createRange().text;
}
}
</script>
ÔÚ FireFox Ï»ñÈ¡ input »òÕß textarea ÖÐÑ¡ÖеÄÎÄ×Ö£¬¿ÉÒÔÓÃÏÂÃæµÄ·½·¨£º
<script type="text/javascript">
// ˵Ã÷£ºFireFox Ï»ñÈ¡ input »òÕß textarea ÖÐÑ¡ÖеÄÎÄ×Ö
// ÕûÀí£ºhttp://www.codebit.cn
function getTextFieldSelection(e) {
if (e.selectionStart != undefined && e.selectionEnd != undefined) {
var start = e.selectionStart;
var end = e.selectionEnd;
return e.value.substring(start, end);
}
else return ""; // Not supported on this browser
}
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD
Ïà¹ØÎĵµ£º
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="return f ......
¡¶Îò͸javascript¡·Ñ§Ï°±Ê¼Ç
Ò»¡¢ ǰÑÔ
http://blog.csdn.net/soldierluo/archive/2010/02/25/5326520.aspx
¶þ¡¢ »Ø¹é¼òµ¥¡¢»ù±¾ÀàÐÍ
http://blog.csdn.net/soldierluo/archive/2010/02 ......
1.document.write( " "); Êä³öÓï¾ä
2.JSÖеÄ×¢ÊÍΪ//
3.´«Í³µÄHTMLÎĵµË³ÐòÊÇ:document- >html- >(head,body)
4.Ò»¸öä¯ÀÀÆ÷´°¿ÚÖеÄDOM˳ÐòÊÇ:window- >(navigator,screen,history,location,document)
5.µÃµ½±íµ¥ÖÐÔªËØµÄÃû³ÆºÍÖµ:document.getElementById( "±íµ¥ÖÐÔªËØµÄID號 ").name(»òvalue)
6.Ò»¸ö ......
ÔÚJavaScriptÖпÉÒÔ´´½¨ÈýÖÖÏûÏ¢¿ò£º¾¯¸æ¿ò¡¢È·ÈÏ¿ò¡¢Ìáʾ¿ò
¾¯¸æ¿ò¾³£ÓÃÓÚÈ·±£Óû§¿ÉÒԵõ½Ä³Ð©ÐÅÏ¢¡£µ±¾¯¸æ¿ò³öÏÖºó£¬Óû§ÐèÒªµã»÷È·¶¨°´Å¥²ÅÄܼÌÐø½øÐвÙ×÷¡£
Óï·¨£º
alert("Îı¾")
È·ÈÏ¿òÓÃÓÚʹÓû§¿ÉÒÔÑéÖ¤»òÕß½ÓÊÜijЩÐÅÏ¢¡£µ±È·ÈÏ¿ò³öÏÖºó£¬Óû§ÐèÒªµã»÷È·¶¨»òÕßÈ¡Ïû°´Å¥²ÅÄܼÌÐø½øÐвÙ×÷¡£Èç¹ûÓû§µã»÷È·ÈÏ£¬Ä ......