JavaScriptÅжÏä¯ÀÀÆ÷ÀàÐͼ°°æ±¾
ͨ¹ý·ÖÎö¸÷Ààä¯ÀÀÆ÷µÄuserAgentÐÅÏ¢£¬²»Äѵóö·Ö±æ¸÷Ààä¯ÀÀÆ÷¼°Æä°æ±¾µÄÕýÔò±í´ïʽ¡£¶øÇÒ£¬¶Ôä¯ÀÀÆ÷ÀàÐ͵ÄÅжϺͰ汾µÄÅжÏÍêÈ«¿ÉÒÔºÏΪһÌ嵨½øÐС£ÓÚÊÇ£¬ÎÒÃÇ¿ÉÒÔд³öÏÂÃæµÄ´úÂ룺
<script type="text/javascript">
var Sys = {};
var ua = navigator.userAgent.toLowerCase();
var s;
(s = ua.match(/msie ([\d.]+)/)) ? Sys.ie = s[1] :
(s = ua.match(/firefox\/([\d.]+)/)) ? Sys.firefox = s[1] :
(s = ua.match(/chrome\/([\d.]+)/)) ? Sys.chrome = s[1] :
(s = ua.match(/opera.([\d.]+)/)) ? Sys.opera = s[1] :
(s = ua.match(/version\/([\d.]+).*safari/)) ? Sys.safari = s[1] : 0;
//ÒÔϽøÐвâÊÔ
if (Sys.ie) document.write('IE: ' + Sys.ie);
if (Sys.firefox) document.write('Firefox: ' + Sys.firefox);
if (Sys.chrome) document.write('Chrome: ' + Sys.chrome);
if (Sys.opera) document.write('Opera: ' + Sys.opera);
if (Sys.safari) document.write('Safari: ' + Sys.safari);
</script>
ÆäÖУ¬²ÉÓÃÁË“... ? ... : ...”ÕâÑùµÄÅжϱí´ïʽÀ´¾«¼ò´úÂë¡£ÅжÏÌõ¼þÊÇÒ»Ìõ¸³ÖµÓï¾ä£¬¼ÈÍê³ÉÕýÔò±í´ïʽµÄÆ¥Åä¼°½á¹û¸´ÖÆ£¬ÓÖÖ±½Ó×÷ΪÌõ¼þÅжϡ£¶øËæºóµÄ°æ±¾ÐÅÏ¢Ö»Ðè´ÓÇ°ÃæµÄÆ¥Åä½á¹ûÖÐÌáÈ¡¼´¿É£¬ÕâÊǷdz£¸ßЧµÄ´úÂë¡£
ÒÔÉϵĴúÂë¶¼ÊÇΪÁË´òÔìǰ¶Ë¿ò¼ÜËù×öµÄÔ¤ÑУ¬²¢ÔÚÎå´óä¯ÀÀÆ÷ÉϲâÊÔͨ¹ý¡£½ñºó£¬ÅжÏijÖÖä¯ÀÀÆ÷Ö»ÐèÓÃif(Sys.ie)»òif(Sys.firefox)µÈÐÎʽ£¬¶ø
Ïà¹ØÎĵµ£º
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´úÂë¿ÉÒÔÓëHTML±êǩһÆðÖ±½Ó·ÅÔÚǰ¶ËÒ³ÃæÖУ¬µ«Èç¹ûJS´úÂë¶àµÄ»°Ò»·½Ãæ²»ÀûÓÚά»¤£¬ÁíÒ»·½ÃæÒ²¶ÔËÑË÷ÒýÇæ²»ÓѺã¬Òò
ÎªÒ³ÃæÒò´Ë¶ø±äµÃÓ·Ö×£»ËùÒÔÒ»°ãÓÐÁ¼ºÃ¿ª·¢Ï°¹ßµÄ³ÌÐòÔ±¶¼»á°Ñjavascript´úÂë·Åµ½¶ÀÁ¢µÄjsÎļþÖУ¬ÆäËûÒ³ÃæÍ¨¹ýÒýÈë¸ÃjsÎļþÀ´Ê¹ÓÃÏàÓ¦µÄ
javascript´úÂë¡£
½ñÌìÔÚ×öÒ»¸öСÐÂÎÅϵͳµÄ¹ÜÀí ......
1.´´½¨½Úµã²¢Ìí¼ÓÄÚÈÝ:ʹÓõķ½·¨:createElementºÍcreateTextNode
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>HTML DOM</title>
&nbs ......
´úÂëʾÀý
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>ÎÞ±êÌâÎĵµ</title>
</head>
<mce:style><!--
.man{ float:left; background:#9af; margin:3px; padding:3px; cursor:default}
--></mce:style>< ......
flex ºÍjavascript»¥Ïàµ÷Óá£
Ò»¡¢flex µ÷ÓÃjavascript
Ö»ÐèʹÓþ²Ì¬µÄExternalInterface.call¾Í¿ÉÒÔÁË¡£
call ·½·¨ÖÁÉÙÒªÇóÒ»¸ö²ÎÊý£¬¾ÍËùµ÷ÓöÊýµÄÃû³Æ¡£
Ò²¿ÉÒÔ´«µÝ²ÎÊý¡£
È磺
ExternalInterface.call("alert","hello");
"hello"¾ÍÊÇ×÷Ϊalertµ ......