zoukankan      html  css  js  c++  java
  • 获取url中的参数

    url地址

    http://localhost:8080/xx/xx.htm?columnName=测试&columnId=2c908095636c27e601636cb335550006
    

      注意:如果url中有中文,先提前用codeURI转码

    获取url项目路径

    var curPath=window.document.location.href;
    var localhostPath=curPath.substring(0,curPath.lastIndexOf("/")+1);
    

      参考地址:http://www.cnblogs.com/l412382979/p/8574813.html

    获取url中的参数

    function getRequest(){
    	var strs;
         //将url再次进行解码,这样中文就不会出现乱码了 var url=decodeURI(location.search); var theRequest=new Object(); if(url.indexOf("?")!=-1){ var str=url.substr(1); strs=str.split("&"); for(var i=0;i<strs.length;i++){ theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]); } return theRequest; } }

      使用方法

    var req=getRequest();
    alert(req["columnName"]);
    

      

  • 相关阅读:
    IHttpHandler and HttpModule
    sql page reship
    prototype
    google search engine theory
    ghost
    sql split
    Missing you is a kind of my deeppain in my life
    file control
    a story of c#(reship)
    teacher and student(reship)
  • 原文地址:https://www.cnblogs.com/l412382979/p/9176999.html
Copyright © 2011-2022 走看看