zoukankan      html  css  js  c++  java
  • location.href 与 location.search

    1.document.location.href 返回完整的 URL。 如:http://www.cftea.com/foo.asp?p=1

    引用

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

    通过这个函数就可以轻易取到连接后面带的参数,这个可用户父窗口向子窗口传递参数
    eg:
    Java代码 复制代码
    1. function openTable(id){   
    2. var feathers="status=no,width=650px,height=670px,top=0px,menubar=no,resizable=no,scrollbars=yes,toolbar=no,channelmode=no";   
    3. var openWin = window.open("allInfo.html?"+id+","+new Date().getTime(),"declare",feathers);   
    4. openWin.focus();   
    5. }  

    在allInfo.html页面中如果我们要获取id的值的话,可以这样获得
    Java代码 复制代码
    1. <script type="text/javascript">   
    2.     var params= window.location.search;//params:?id,date   
    3.        
    4.     var arr = params.substring(1).split(",");   
    5.        
    6.     var id = arr[0];   
    7. </script>  


    2.document.location.search 返回 URL 中的 QueryString 部分,含“?”。 如:?p=1

  • 相关阅读:
    centos mongodb
    CentOS YUM 安装 TOMCAT6
    Linux切换工作目录命令:cd
    CentOS中JAVA_HOME的环境变量设置
    用Navicat for MySQL 连接 CentOS 6.5
    CentOS上开启MySQL远程访问权限
    centos7下yum安装mysql
    long数值 转换为时间
    安卓开发_浅谈AsyncTask
    ScrollView与ListView的事件冲突
  • 原文地址:https://www.cnblogs.com/quanhai/p/1558383.html
Copyright © 2011-2022 走看看