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

javascriptдÀ෽ʽ֮Èý

È¡Ç°ÃæÁ½ÖÖµÄÓŵ㣺
a¡¢Óù¹Ô캯ÊýÀ´¶¨ÒåÀàÊôÐÔ£¨×ֶΣ©
b¡¢ÓÃÔ­ÐÍ·½Ê½À´¶¨ÒåÀàµÄ·½·¨¡£
¾ÍÓÐÁ˵ÚÈýÖÖ·½Ê½¡£ÕâÖÖ·½Ê½Ã²ËƲÉÓõÄÈ˽϶ࡣ
3¡¢×ۺϹ¹Ô캯Êý/Ô­ÐÍ
/**
* PersonÀࣺ¶¨ÒåÒ»¸öÈË£¬ÓиöÊôÐÔname£¬ºÍÒ»¸ögetName·½·¨
* @param {String} name
*/
function Person(name) {
this.name = name;
}
Person.prototype.getName = function() {
return this.name;
}

ÕâÑù£¬¼´¿Éͨ¹ý¹¹Ô캯Êý¹¹Ô첻ͬnameµÄÈË£¬¶ÔÏóʵÀýÒ²¶¼¹²ÏígetName·½·¨£¬²»»áÔì³ÉÄÚ´æÀË·Ñ¡£
µ«ËƺõÕâÑùµÄ´úÂë·ç¸ñËÆºõÈÔȻûÓÐjavaµÄÀàÄÇô½ô´Õ£¬°ÑÊôÐÔ£¬¹¹Ôì·½·¨£¨º¯Êý£©£¬·½·¨¶¼°üÔÚ´óÀ¨ºÅÄÚ¡£
public class Person {
//ÊôÐÔ£¨×ֶΣ©
String name;
//¹¹Ôì·½·¨£¨º¯Êý£©
Person(String name) {
this.name = name;
}
//·½·¨
String getName() {
return this.name;
}
}

ΪÁËÈÃjs´úÂë·ç¸ñ¸ü½ô´Õ£¬°Ñ¹ÒÔÚprototypeµÄ·½·¨´úÂëÒÆµ½function PersonµÄ´óÀ¨ºÅÄÚ¡£
function Person(name) {
this.name = name;
Person.prototype.getName = function() {
return this.name;
}
}

ËÆºõºÜÉñÆæ£¬»¹ÄÜÕâôд°¡£¡ÑéÖ¤Ò»ÏÂ
var p1 = new Person("Jack");
var p2 = new Person("Tom");
console.log(p1.getName());//Jack
console.log(p2.getName());//Tom

ûÓб¨´í£¬¿ØÖÆÌ¨Ò²ÕýÈ·Êä³öÁË¡£ËµÃ÷¿ÉÒÔÕâôд£¬ºÇºÇ¡£
àÅ£¬ËƺõºÜÍêÃÀ¡£
a ¡¢¿ÉÒÔͨ¹ý´«²Î¹¹Ôì¶ÔÏóʵÀý
b ¡¢¶ÔÏóʵÀý¶¼¹²Ïíͬһ·Ý·½·¨²»Ôì³ÉÄÚ´æÀË·Ñ
c ¡¢´úÂë·ç¸ñÒ²±È½Ï½ô´Õ
µ«Ã¿´ÎnewÒ»¸ö¶ÔÏóµÄʱºò¶¼»áÖ´ÐР 
Person.prototype.getName = function() {
        return this.name;
}
Ôì³ÉÁ˲»±ØÒªµÄÖØ¸´µÄÔËËã¡£ÒòΪgetName·½·¨¹ÒÔÚprototypeÉÏÖ»ÐèÖ´ÐÐÒ»´Î¼´¿É¡£Ö»ÐèÉÔ΢¸ÄÔìÏ£º
function Person(name) {
this.name = name;
if(Person._init==undefined) {
alert("ÎÒÖ»Ö´ÐÐÒ»´Î£¡");
Person.prototype.getName = function() {
return this.name;
}
Person._init = 1;
}
}

newÁ½¸ö¶ÔÏó£¬
var p1 = new Person("Andy");//µÚÒ»´Înew»áµ¯³ö'ÎÒÖ»Ö´ÐÐÒ»´Î£¡'
var p2 = new Person("Lily");//ÒÔºónewµÄ¶ÔÏó²»»áÔÙÖ´ÐÐÁË


Ïà¹ØÎĵµ£º

Javascript ¶ÔÏóµÄ±È½Ï

Õâ¸öËæ±ÊÆäʵÊÇΪÁ˸ÐлÇå·çЦ¸øµÄÒ»¸öÌáʾ£¬²»½ö½öÊǸæËßÎÒÔõôÅжÏÊý×飬¸üÈÃÎÒÓÐÁËÈÏÕæ¶ÁÒ»¶Á ¡¶javascriptȨÍþÖ¸ÄÏ¡·µÄÏë·¨¡£
±È½ÏºÍ¿½±´ÆäʵÊÇÒ»»ØÊ£¬´úÂëÈçÏ£º
//
//Compare object function
//
function Compare(fobj,sobj)
{
    var ftype = typ ......

javascript³£ÓÃ

calcu()  ----º¯ÊýʵÏÖÁ½¸öÊýÏà³Ë
document.write();  ---´òÓ¡
document.calc.ÔªËØÃû.value;  --»ñµÃ±íµ¥µÄÖµ
document.±íµ¥Ãû¡£±íµ¥ÔªËØÃû¡£value  Ϊ±íµ¥¸³Öµ
¶¨Ò庯Êý£º
 function  Ãû×Ö()
 {
    //javaScriptÔ¤Óï¾ä
 }
 onClick="º¯ÊýÃû";  ......

[·­Òë]High Performance JavaScript(004)

XMLHttpRequest Script Injection  XHR½Å±¾×¢Èë
    Another approach to nonblocking scripts is to retrieve the JavaScript code using an XMLHttpRequest (XHR) object and then inject the script into the page. This technique involves creating an XHR object, downloading the JavaScript f ......

һЩjavascriptÌâÄ¿

ȺÀïÌÖÂÛ¹ýµÄÌâÄ¿£¬·ÖÏíһϡ£
function test(){
var m=n=1;
alert(m);
}
alert(n);
//ÒòΪtestº¯ÊýûÓÐÖ´ÐУ¬³Ì¶È¿ØÖÆÁ÷²»ÄܽøÈë½øÐнâÎö£¬ÀïÃæµÄ¶«Î÷¶ÔÍâÃæ²»¿É¼û£¬Òò´Ë±¨´í
function test(){
var m=n=1;
alert(m);
}
test();
alert(n);
//µ±testÖ´Ðкó£¬Í ......

asp.net×¢²áJavascriptµÄ·½·¨

1¡¢IsStartupScriptRegistered£º¶ÔÏóÊÇ·ñ×¢²áÁËÆôÓýű¾¡£
2¡¢IsClientScriptBlockRegistered£º¶ÔÏóÊÇ·ñ×¢²áÁ˿ͻ§¶Ë½Å±¾¿é¡£
3¡¢IsClientScriptIncludeRegistered£º¶ÔÏóÊÇ·ñ×¢²áÁ˿ͻ§¶Ë½Å±¾°üº¬¡£
µÚÒ»¸öÀý×Ó£º
string info = "<script>alert('ÄãºÃÂð£¿');</script>";
//ÅжÏʼþÊÇ·ñ±»×¢²á£¬Ð´ÈëÇ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ