js正则备忘

<script>
function lang_mouseover(obj){
var path = String(window.location);
var re = /l=/;
if(!re.test(path)){
obj.href=path+'&l='+obj.id;
}else{
obj.href=path.replace(/l=\w{2}(-[a-z]{2})?/g,'l='+obj.id);
}
}

</script>

<a href="#" class="lang" id="zh-cn" onmouseover="lang_mouseover(this)">中文</a> | <a href="#" class="lang" id="en" onmouseover="lang_mouseover(this)">English</a>

posted @ 2012-12-18 16:43  上帝爱编程  阅读(123)  评论(0编辑  收藏  举报