phpºÍjavascriptͨѶ
°ÑphpÊý¾Ý»òÖµ´«µÝ¸øjs
£ººÜ¼òµ¥£¬Ö±½ÓÔÚjsÖÐʹÓÃphp´úÂ룬»ì±à¼´¿É¡£
°ÑjsÊý¾Ý´«µÝ¸øphp
£º¿ÉÒÔʹÓôò¿ªÐ´°¿ÚµÄ·½Ê½£¬Í¨¹ýurlµØÖ·°ÑÊý¾Ý´«µÝ¹ýÈ¥¡£Ò²¿ÉÒÔʹÓÃajax£¬Í¨¹ýget»òpost´«µÝ¸øphp£¬Ò²¿ÉÒÔ±£´æcookieÈÃphpÀ´¶Á¡£
ÔÚ´«µÝÊý¾Ý¹ý³ÌÖпÉÄÜÓöµ½ÖÐÎıàÂë
ÎÊÌ⣬¿ÉÒÔͳһ±àÂ뷽ʽΪjsµÄescape£¬unescape£¬Ò²¿ÉÒÔͳһ±àÂ뷽ʽΪurlencode£¬urldecode
ÓÉÓÚphpÓк¯Êýurlencode£¬urldecode£¬Õâ¸öʱºòÐèÒªjsÀ´ÊµÏָñàÂ룬ÏÂÃæÊÇjsµÄ±àÂë
function UrlEncode(str)
{
var ret="";
var strSpecial="!\"#$%&()*+,/:;<=>?[]^`{|}~%"; var tt="";
for(var i=0;i<str.length;i++)
{
var chr = str.charAt(i);
var c=str2asc(chr);
tt += chr+":"+c+"n";
if(parseInt("0x"+c) > 0x7f)
{
ret+="%"+c.slice(0,2)+"%"+c.slice(-2);
}
else
{
if(chr==" ")
ret+="+";
else if(strSpecial.indexOf(chr)!=-1)
ret+="%"+c.toString(16);
else
ret+=chr;
}
}
return ret;
}
UrlDecode
function UrlDecode(str){
var ret="";
for(var i=0;i<str.length;i++)
{
var chr = str.charAt(i);
if(chr == "+")
{
ret+=" ";
}
else if(chr=="%")
{
var asc = str.substring(i+1,i+3);
if(parseInt("0x"+asc)>0x7f)
{
ret+=asc2str(parseInt("0x"+asc+str.substring(i+4,i+6)));
i+=5;
}
else
{
ret+=asc2str(parseInt("0x"+asc));
i+=2;
}
}
else
{
ret+= chr;
}
}
return ret;
}
ÓÉÓÚjsÓк¯ÊýescapeºÍunecapse£¬ÐèÒªphpÀ´ÊµÏָñàÂ룬ÏÂÃæÊ
Ïà¹ØÎĵµ£º
ugmbbc·¢²¼ÓÚ 2009-11-14 09:41:43| 7628 ´ÎÔĶÁ ×ÖÌ壺´ó С ´òÓ¡Ô¤ÀÀ
var ReTitle = '»Ø¸´:Google ÅÅÃûÖÐµÄ 10 ¸ö×îÖøÃûµÄ JavaScript ¿â';
¸ÐлCOMSHARP CMSµÄͶµÝ
ÐÂÎÅÀ´Ô´:tripwiremagazine.com
JavaScript ÊÇ Web ¿ª·¢ÓëÉè¼ÆÖв»¿É»òȱµÄ¶«Î÷£¬²»¹ÜÊÇÒ»¸ö¼òµ¥µÄÍøÒ³»¹ÊÇÒ»¸öרҵµÄÕ¾µã£¬Ò²²»¹ÜÄãÊǸßÊÖ»¹ÊDzËÄñ ......
Jsѧϰ£¨¶þ£©
ÎÒÃÇÓ¦¸ÃÒѾ·¢ÏÖ£¬´´½¨¹«ÓÐʵÀý³ÉÔ±ÆäʵºÜ¼òµ¥£¬Ò»ÖÖ·½Ê½ÊÇͨ¹ýÔÚÀàÖиø this.memberName À´¸³Öµ£¬Èç¹ûÖµÊǺ¯ÊýÖ®ÍâµÄÀàÐÍ£¬ÄǾÍÊǸö¹«ÓÐʵÀý×ֶΣ¬Èç¹ûÖµÊǺ¯ÊýÀàÐÍ£¬ÄǾÍÊǹ«ÓÐʵÀý·½·¨¡£ÁíÍâÒ»ÖÖ·½Ê½ÔòÊÇͨ¹ý¸ø className.prototype.memberName ¸³Öµ£¬¿É¸³ÖµµÄÀàÐ͸ú this.memberName ÊÇÏàͬµÄ¡£
µ½µ×ÊÇ ......
Jsѧϰ£¨Èý£©
ÁíÍâÒ»ÖÖ·½Ê½Í¨¹ýÖ±½ÓʵÀý»¯ÄäÃûº¯Êý·½Ê½À´´´½¨´øÓÐ˽Óо²Ì¬³ÉÔ±µÄÀàµÄÀý×Ó¸úÉÏÃæµÄÀý×ÓºÜÏàËÆ£º
new function() {
// private static fields
var s_first = 1;
var s_second = 2;
// private static methods
&n ......
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Wanna tell her - interactive DHTML </title>
<meta http-equiv="imagetoolbar" content="no">
<style type="text/css">
html {
overflow: h ......
JSÖÐÊý×éµÄÅúÁ¿Ìî³ä·½Ê½:
1.ÔÚÉùÃ÷ʱͬʱ½øÐÐÌî³ä
var beatles = Array("John","Paul","George","Ringo");
2.ÎÒÃÇÉõÖÁÓò»×ÅÃ÷È·µØ±íÃ÷ÎÒÃÇÊÇÔÚ´´½¨Êý×é.ÊÂʵÉÏ,Ö»ÐèÓÃÒ»¶Ñ·½À¨ºÅÀ¨ÆðÀ´¾Í×ãÒÔ´´½¨ÎÒÃÇÏëÒªµÄÊý×éÁË:
......