在jsp中如何用js获取当前url的参数,并且通过比较实现一些功能
比如,当前的url为http://localhost:8080/socialsys/first.jsp?id=6,我怎么通过js来获取id后面的参数。谢谢各位能够指点,在线等。
------解决方案--------------------var url = window.location.href //获取当前URL 
 var param = url.split( "? ")[1].split( "= ")[1];//取得参数 
 if(param == 6) { 
 var hideEle = document.getElementById( "你要隐藏的对象的id "); //获得你要隐藏的对象 
 hideEle.setAttribute( "className ",  "hide "); //隐藏 
 } 
 else { 
 var hideEle = document.getElementById( "你要隐藏的对象的id "); //获得你要隐藏的对象 
 hideEle.setAttribute( "className ",  "show "); //显示 
 }   
 页面上需要定义css style: 
 .hide{ 
 display: none; 
 } 
 .show{ 
 display: block; 
 }