location.search是从当前URL的?号开始的字符串
如:http://www.51js.com/viewthread.php?tid=22720
它的search就是?tid=22720

通过这个函数就可以轻易取到连接后面带的参数,这个可用户父窗口向子窗口传递参数
eg:
Java代码:

function openTable(id){
    var feathers="status=no,width=650px,height=670px,top=0px,menubar=no,resizable=no,scrollbars=yes,toolbar=no,channelmode=no";
    var openWin = window.open("allInfo.html?"+id+","+new Date().getTime(),"declare",feathers);
    openWin.focus();
}

function openTable(id){
    var feathers="status=no,width=650px,height=670px,top=0px,menubar=no,resizable=no,scrollbars=yes,toolbar=no,channelmode=no";
    var openWin = window.open("allInfo.html?"+id+","+new Date().getTime(),"declare",feathers);
    openWin.focus();
}

在allInfo.html页面中如果我们要获取id的值的话,可以这样获得
Java代码

<script type="text/javascript">
    var params= window.location.search;//params:?id,date
    var arr = params.substring(1).split(",");
    var id = arr[0];
</script>

(转)window.location.search的用法的更多相关文章

  1. window.location.search的用法 和 地址栏的的javsscript编码与解码

    ocation.search是从当前URL的?号开始的字符串 如:http://www.51js.com/viewthread.php?tid=22720 它的search就是?tid=22720 e ...

  2. js中的window.location.search的用法与作用。

    用该属性获取页面 URL 地址: window.location 对象所包含的属性 属性 描述 hash 从井号 (#) 开始的 URL(锚) host 主机名和当前 URL 的端口号 hostnam ...

  3. window.location属性用法及解决一个window.location.search为什么为空的问题

    通常用window.location该属性获取页面 URL 地址: 1.什么是window.location? 比如URL:http://b.a.com:88/index.php?name=kang& ...

  4. window.location.search

    http://i.cnblogs.com/EditPosts.aspx?opt=1&opt2=x 就拿上面这个URL来说window.location.search的返回值为opt=1& ...

  5. window.location.search作用

    window.location.search.substr(1).split("&") 这里面的相关属性和时间还有参数能具体说明一下吗?window.location wi ...

  6. [置顶] 初识window.location.search

    window.location.search是从当前URL的?号开始的字符串 如:http://www.domain.com/item?id=0064014 它的search就是?id=0064014

  7. 通过window.location.search获取页面url传递的参数

    function GetQueryString(name) { var reg = new RegExp("(^|&)" + name + "=([^&] ...

  8. javascript中window.location.search的用法和作用。

    用该属性获取页面 URL 地址: window.location 对象所包含的属性 属性 描述 hash 从井号 (#) 开始的 URL(锚) host 主机名和当前 URL 的端口号 hostnam ...

  9. window.location.search 在url中有?name=value时仍为‘’的情况

    1,当页面有hash#值 而?name=value在hash #的串后面将会有这种结果 2,为什么 window.location.search 为空? 答:注意上面的search和hash的区别,如 ...

随机推荐

  1. 浅述Oracle分布式事务概念

    着系统的复杂性不断增加,我们所面对的分布式系统渐渐增加.分布式文件系统.分布式消息队列系统等等层出不穷,在一些行业特别是互联网行业应用广泛.分布式数据库也是目前使用比较常用的分布式系统之一. 简单来说 ...

  2. JQ 遍历节点

    .children() : 取得匹配元素的子元素集合 .next() :取得匹配元素后面紧邻的同辈元素 .prev() :取得匹配元素前面紧邻的同辈元素 .siblings() :取得匹配元素前.后的 ...

  3. poj 1080 dp

    基因配对 给出俩基因链和配对的值  求配对值得最大值  简单dp #include<iostream> #include<stdio.h> #include<string ...

  4. 多维背包 hrbudt 1335 算法与追MM

    hrbust #include<string.h> //多进制储存数,第i位进制维back[i]+1,可以避免重复 #include<stdio.h> using namesp ...

  5. 1.1C++入门 未完待续。。。

    第一个C++程序: #include<iostream> int main() { std::cout << "Hello World !" << ...

  6. 【转】c/c++各种字符、字符串类型转换

    itoa   功 能:把一整数转换为字符串   用 法:char *itoa(int value, char *string, int radix);   详细解释:itoa是英文integer to ...

  7. 如何用正则将多个空格看成一个空格结合spllit()方法将文本数据入库

    关键的代码和正则表达式在这里 while((line=br.readLine())!=null) { String[] data=new String[4]; data=line.split(&quo ...

  8. php 之 类,对象(三)多态性,函数重载,克隆

    一.三大特性之三 多态性(在php中表象不明显)1.概念:当父类引用指向子类实例时,由于子类对父类函数进行了重写,导致我们在使用该引用去调用相应的方法显示出的不同.2.发生条件:1.必须有继承 2. ...

  9. ubuntu 下GIT的安装

    linux下软件的安装方式有多种,最简单的莫过于从软件中心直接安装了或者用命令行直接安装 sudo apt-get install git 但是这样的安装却使我们体会不到最新版本的功能,如果我们想要体 ...

  10. 对拍 For Linux

    #!/bin/sh g++ -g gene.cpp -o gene g++ -g a.cpp -o a g++ -g b.cpp -o b while true; do  ./gene > in ...