zoukankan      html  css  js  c++  java
  • (转)window.location.search的用法

    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>

  • 相关阅读:
    算法初探
    OIer数学相关
    算法初探
    MySQL事务
    MySQL多表查询
    数据库的设计
    winform选择文件夹
    获取上次打开目录
    C#拆分中文和数字字符串
    uCharts如何设置双Y轴,左侧一个右侧一个,数据源与对应的Y轴绑定
  • 原文地址:https://www.cnblogs.com/wanshutao/p/4043327.html
Copyright © 2011-2022 走看看