惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

AI
AI
TaoSecurity Blog
TaoSecurity Blog
H
Heimdal Security Blog
Help Net Security
Help Net Security
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Microsoft Azure Blog
Microsoft Azure Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Google DeepMind News
Google DeepMind News
爱范儿
爱范儿
The Cloudflare Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
人人都是产品经理
人人都是产品经理
大猫的无限游戏
大猫的无限游戏
N
News | PayPal Newsroom
V2EX - 技术
V2EX - 技术
博客园 - 【当耐特】
D
Darknet – Hacking Tools, Hacker News & Cyber Security
S
Secure Thoughts
C
CERT Recently Published Vulnerability Notes
罗磊的独立博客
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
P
Privacy & Cybersecurity Law Blog
有赞技术团队
有赞技术团队
S
Schneier on Security
S
SegmentFault 最新的问题
Google Online Security Blog
Google Online Security Blog
H
Hacker News: Front Page
The Last Watchdog
The Last Watchdog
Schneier on Security
Schneier on Security
PCI Perspectives
PCI Perspectives
IT之家
IT之家
Project Zero
Project Zero
博客园 - 司徒正美
P
Privacy International News Feed
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Jina AI
Jina AI
Security Latest
Security Latest
Hacker News - Newest:
Hacker News - Newest: "LLM"
腾讯CDC
C
CXSECURITY Database RSS Feed - CXSecurity.com
阮一峰的网络日志
阮一峰的网络日志
C
Check Point Blog
aimingoo的专栏
aimingoo的专栏
V
Vulnerabilities – Threatpost
W
WeLiveSecurity
NISL@THU
NISL@THU
Webroot Blog
Webroot Blog
N
Netflix TechBlog - Medium
L
Lohrmann on Cybersecurity

博客园 - 极地雪狼

C#扩展方法 C#对象与集合初始化器 C#泛型类型参数约束 C#可访问性(摘自《C#编程语言详解》) C#委托(摘自《C#编程语言详解》) C#程序结构(摘自《C#编程语言详解》) Linux系统运行级别 影响互联网效率的瓶颈(持续更新中) 大数据量高并发的数据库优化(转) lucene、lucene.NET详细使用与优化详解 实现多重标准搜索 Document对象内容集合 [转]IIS被挂马,解决一法 解决需求管理不当造成的项目失败 Lucene 学习笔记(三)——搜索解析 Lucene 学习笔记(二)——搜索方式(二) Lucene 学习笔记(二)——搜索方式(一) Lucene 学习笔记(一)——基本对象及结构 关于在ASP.NET环境下,利用FFMPEG视频格式转换的问题。
在HTML中用JS接收参数
极地雪狼 · 2010-01-29 · via 博客园 - 极地雪狼

先介绍一下JS中处理URL的方法:

  • <script languge=javascript>  
  • alert(window.location.pathname);   --返回   /test/test.htm   
  • alert(window.location.search);     --返回   ?id=1  
  • alert(window.location.href);       --返回   http://localhost/test/test.htm?id=1  
  • </script>
  • ---------------------------------

    location对象 

    含有当前URL的信息. 

    属性 

    href 整个URL字符串. 
    protocol 含有URL第一部分的字符串,如http: 
    host 包含有URL中主机名:端口号部分的字符串.如//www.zzcn.net/server/ 
    hostname 包含URL中主机名的字符串.如http://www.zzcn.net/ ;
    port 包含URL中可能存在的端口号字符串. 
    pathname URL中"/"以后的部分.如~list/index.htm 
    hash "#"号(CGI参数)之后的字符串. 
    search "?"号(CGI参数)之后的字符串.

    在HTML中用JS接收参数用到的函数
    function getParameter(param)
    {
    var query = window.location.search;
    var iLen = param.length;
    var iStart = query.indexOf(param);
    if (iStart == -1)
       return "";
    iStart += iLen + 1;
    var iEnd = query.indexOf("&", iStart);
    if (iEnd == -1)
       return query.substring(iStart);

    return query.substring(iStart, iEnd);
    }

    使用的时候:var temp = getParameter("传过来的参数");

    必须得xx.htm?xx=xx这样用啊。呵呵,,,