$sql="update vote set count=count+1 where id=$id"
if(mysql_query($sql))
{
$_SESSION["vote"]=session_id()
?>
<script language="javascript">alert("投票成功,点确定查看结
果")location.href="index.php?id=ck"</script>
String.prototype.getQuery = function(name){
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)")
var r = this.substr(this.indexOf("\?")+1).match(reg)
if (r!=null) return unescape(r[2])return null
}
var s = "web1.aspx?status=item&mode=edit"
alert(s.getQuery("status"))
alert(s.getQuery("mode"))
String.prototype.getQuery = function(name)
的意思是为String对象增加一个getQuery(name)方法.
获取地址栏参数值http://www.xxx.com/index.html?ver=1.0&id=6#page1
getQueryVariable(ver)// 1.0
getQueryVariable(id) // 6
我们可以用javascript获得其中的各个部分
1、整个URl字符串(在浏览器中就是完整的地址栏 http://www.xxx.com/index.html?ver=1.0&id=6#page1 )
本例返回值: ( http://www.xxx.com/index.html?ver=1.0&id=6#page1 )
2、URL 的协议部分 ( http://www.xxx.com/index.html?ver=1.0&id=6#page1 )
本例返回值:http:
3、URL 的主机部分 ( http://www.xxx.com/index.html?ver=1.0&id=6#page1 )
本例返回值: www.xxx.com
4、URL 的端口部分 ( http:192.168.1.152:8080/index.html)
如果采用默认的80端口(update:即使添加了:80),那么返回值并不是默认的80而是空字符
本例返回值:"8080"
5、URL 的路径部分( http://192.168.1.145/community/page/index.html?categoryId=#page3 )
本例返回值:/community/page/index.html
6、查询(参数)部分
除了给动态语言赋值以外,我们同样可以给静态页面,并使用javascript来获得相信应的参数值
本例返回值:?ver=1.0&id=6
7、锚点 ( http://192.168.1.145/community/page/index.html?categoryId=#page3 )
本例返回值:#page3