Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

JavaScript£¬µÈ±ÈÀýËõ·ÅͼƬµÄº¯Êý

    ÔÚWebÉÏÏÔʾͼƬ£¬Í¨³£¶¼»áÓÐͼƬÏÔʾ±ÈÀýÎÊÌ⣬Èç¹û²»¸ø<img />ÏÞÖÆwidthºÍheight£¬ÄÇôÈç¹ûͼƬ´óÁ˾ͻὫÕû¸öÒ³Ãæ¼·ÂÒ£¬Í¼Æ¬Ð¡ÁËÓÖ»áʹͼƬʧÕæ¡£
    ÎÒµÄÐèÇóÈçÏ£º
        1¡¢Ô¤Ïȶ¨ÒåºÃͼƬÏÔʾµÄ±ê×¼¿í¶ÈºÍ¸ß¶È¡£
        2¡¢Èç¹ûͼƬµÄ´óС³¬¹ýÁ˱ê×¼¶¨Ò壬ÄÇôµÈ±ÈÀýѹËõͼƬ¡£
        3¡¢Èç¹ûͼƬµÄ´óСµÈÓÚ±ê×¼¶¨Ò壬ÄÇô°´ÕÕ±ê×¼¿í¶ÈºÍ¸ß¶ÈÏÔʾͼƬ¡£
        4¡¢Èç¹ûͼƬµÄ´óССÓÚ±ê×¼¶¨Ò壬ÄÇô²»¶ÔͼƬ½øÐÐÈκÎѹËõ´¦Àí¡£
    ¿ÉÄÜÊÇÎÒËÑË÷µÄ¹Ø¼ü×Ö²»¶Ô°É£¬ÔÚÍøÉÏÕÒÁ˺ܳ¤Ê±¼ä£¬²ÅÕÒµ½£¬¸Ð¾õºÜºÃʹ¡£
´úÂëÈçÏÂ
<script language="JavaScript">
<!--
//ͼƬ°´±ÈÀýËõ·Å
var flag=false;
function DrawImage(ImgD,iwidth,iheight){
    //²ÎÊý(ͼƬ,ÔÊÐíµÄ¿í¶È,ÔÊÐíµÄ¸ß¶È)
    var image=new Image();
    image.src=ImgD.src;
    if(image.width>0 && image.height>0){
    flag=true;
    if(image.width/image.height>= iwidth/iheight){
        if(image.width>iwidth){ 
        ImgD.width=iwidth;
        ImgD.height=(image.height*iwidth)/image.width;
        }else{
        ImgD.width=image.width; 
        ImgD.height=image.height;
        }
        ImgD.alt=image.width+"×"+image.height;
        }
    else{
        if(image.height>iheight){ 
        ImgD.height=iheight;
        ImgD.width=(image.width*ihe


Ïà¹ØÎĵµ£º

Javascript±äÁ¿×÷ÓÃÓò

ÇëÏÈ¿´ÏÂÌ⣺
if(true)
{
     a = 1;
}
alert(a);  //Êä³öɶ£¿
if(true)
{
    var a = 1; 
}
alert(a);  //ÕâÓÖÊä³öʲô£¿
ÔÚfirefox3.5Ï£¬µÚÒ»¸öÊä³ö1;µÚ¶þ¸öÊä³öundefined£¡£¡£¡
ΪɶÄØ£¿ºÇºÇ£¬±¾ÈËÔÚ´Ë°àÃÅŪ¸«Ò»Ï£º
Ò»°ãÇé¿öÏÂȱʡvarÉùÃ÷ʱ£¬Ä¬È ......

javascriptдÀ෽ʽ֮¶þ

2¡¢Ô­ÐÍ·½Ê½
/**
* PersonÀࣺ¶¨ÒåÒ»¸öÈË£¬ÓиöÊôÐÔname£¬ºÍÒ»¸ögetName·½·¨
*/
function Person(){}
Person.prototype.name = "jack";
Person.prototype.getName = function() { return this.name;}

°ÑÀàµÄÊôÐÔ£¨×ֶΣ©£¬·½·¨¶¼¹ÒÔÚprototypeÉÏ¡£
Ô켸¸ö¶ÔÏó²âÊÔÏ£º
var p1 = new Person();
var ......

javascriptдÀ෽ʽ֮ËÄ

ͨ¹ýÇ°Ã漸ƪµÃÖªjavascriptдÀàÎÞ·Ç»ùÓÚ¹¹Ô캯Êý
ºÍÔ­ÐÍ
¡£¼ÈÈ»ÕâÑù£¬ÎÒÃÇд¸ö¹¤¾ßº¯ÊýÀ´Ð´Àà¡£
/**
* $class дÀ๤¾ßº¯ÊýÖ®Ò»
* @param {Object} constructor
* @param {Object} prototype
*/
function $class(constructor,prototype) {
var c = constructor || function(){};
var p = prototype || {}; ......

Javascript °´¼üʼþ


AS("#...").keypress(function(event) {
        if (navigator.userAgent.toLowerCase().indexOf("mozilla") >= 0) {
         var $key = event.charCode ;
        } else {
         var $key = event. ......

javascript ¼üÅÌʼþ×ܽá


ÔÚ½øÈëÕýÌâÇ°£¬ÎÒÃÇ¿´Ò»ÏÂä¯ÀÀÆ÷¶ÔÓÚ¼üÅ̵ÄһЩĬÈÏʼþ£¬ÕâÓÐÖúÓÚÎÒÃÇÓÃjavascript½Ø»ñ¼üÅÌʼþ¡£
ÔÚformÖУ¬ submitµÄ¿ì½Ý¼üÊÇ enter£¬resetµÄ¿ì½Ý¼üÊÇ esc¡£²»¹ýÔÚ
IE6,safari4,ff3.5,opera10,chromeÖÐ
£¬°´Enter£¬²»µ«¼¤·¢formµÄsubmitʼþ£¬Í¬Ê±Ò²»á¼¤·¢
Ìá½»°´Å¥µÄonclick£¬¼¤·¢Ë³ÐòΪÌá½»°´Å¥µÄ onclick &rarr ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ