<coolcode>
<script type=”text/javascript”>
String.prototype.getQueryString = function(name)
{
var reg = new RegExp(“(^|&|\\?)”+ name +”=([^&]*)(&|$)”), r;
if (r=this.match(reg)) return unescape(r[2]); return null;
};
</script>
<script>
var msg=window.location.href.getQueryString(“msg”);
if (msg)
{
document.write(‘<li>· ’+msg+'</li>’);
}
</script>
</coolcode>
在ff下中文会乱码,参数传递过来时需先escape();
<coolcode>
function phpescape($str){
preg_match_all(“/[\x80-\xff].|[\x01-\x7f]+/”,$str,$newstr);
$ar = $newstr[0];
foreach($ar as $k=>$v){
if(ord($ar[$k])>=127){
$tmpString=bin2hex(iconv(“GBK”,”ucs-2″,$v));
if (!eregi(“WIN”,PHP_OS)){
$tmpString = substr($tmpString,2,2).substr($tmpString,0,2);
}
$reString.=”%u”.$tmpString;
} else {
$reString.= rawurlencode($v);
}
}
return $reString;
}
</coolcode>
参考:
呵呵,好久没来这逛下了!希望博主一切顺利!