看到这样一段代码:

exports.showLogin = function (req, res) {
req.session._loginReferer = req.headers.referer;
res.render('sign/signin');
};

 referer就是跳转到你的网站的之前网站的url引用 

php中可以通过post or get 获取到url中的参数值,最近接触了node那么在nodejs里是怎么做的呢,上代码了!
//需要使用的模块 http   url
当前url   http://localhost:8888/select?aa=001&bb=002
var http = require('http');
var URL = require('url');
http.createServer(function(req, res){
   var arg = url.parse(req.url).query;  //方法一arg => aa=001&bb=002
   var arg = url.parse(req.url, true).query;  //方法二arg => { aa: '001', bb: '002' }
   console.log(arg.aa);//返回001
   console.log(arg.bb);//返回002
   //然后就可以根据所得到的数据处理了

}).listen(8888);//建立服务器并监听端口

获取特定url参数值

var testUrl =  'http://localhost:8888/select?aa=001&bb=002';
var p = URL.parse(testUrl); 
console.log(p.href); //取到的值是:http://localhost:8888/select?aa=001&bb=002
console.log(p.protocol); //取到的值是:http: 
console.log( p.hostname);//取到的值是:locahost
console.log(p.host);//取到的值是:localhost:8888
console.log(p.port);//取到的值是:8888
console.log(p.path);//取到的值是:/select?aa=001&bb=002
console.log(p.hash);//取到的值是:null 
console.log(p.query);// 取到的值是:aa=001
在此值得注意的是当语句 是 var p = URL.parse(testUrl, true) 时,p.query则返回的是如:{aa:'001'}这样的对象, 直接打印p.query则返回 [object Object],这时我们可以这样 写: console.log(
p.query.aa); //取到的值是:001
console.log( p.pathname);//取到的值是:/select

下面附上js的获取方法:
当前URL   http://mj_0203.0fees.net/index.php?aa=001&bb=002
document.location:        http://mj_0203.0fees.net/index.php?aa=001&bb=002
document.URL:             http://mj_0203.0fees.net/index.php?aa=001&bb=002
document.location.href:   http://mj_0203.0fees.net/index.php?aa=001&bb=002
self.location.href:       http://mj_0203.0fees.net/index.php?aa=001&bb=002
top.location.href:        http://mj_0203.0fees.net/index.php?aa=001&bb=002
parent.document.location: http://mj_0203.0fees.net/index.php?aa=001&bb=002
top.location.hostname:    mj_0203.0fees.net
location.hostname:        mj_0203.0fees.net

取当前的地址栏的Url和url中的参数的更多相关文章

  1. Django(命名URL和URL反向解析)

    day67 参考: https://www.cnblogs.com/liwenzhou/articles/8271147.html#autoid-1-4-0 反向解析URL             本 ...

  2. C# 获取地址栏的地址(URL)

    原文地址:http://blog.csdn.net/dingxingmei/article/details/8448009 设当前页完整地址是:http://www.jb51.net/aaa/bbb. ...

  3. js获取当前地址栏的域名、Url、相对路径和参数以及指定参数

    以下代码整理于网络 1.设置或获取对象指定的文件名或路径. window.location.pathname 例:http://localhost:8086/topic/index?topicId=3 ...

  4. JavaScript------获取url地址中的参数

    $(document).ready(function () { //获取地址中的参数(name是字符串) function getParameter(name) { //正则表达式 var reg = ...

  5. getQueryString----获取url中得参数

    /** * 获取url中得参数 * @param name * @returns {null} */ window.getQueryString = function (name) { var reg ...

  6. jQuery获取URL中的参数

    //获取URL地址栏中的参数 function getUrlParam(name) { var reg = new RegExp("(^|&)" + name + &quo ...

  7. js获取当前域名、Url、相对路径和参数以及指定参数

    一.js获取当前域名有2种方法 1.方法一 var domain = document.domain; 2.方法二 var domain = window.location.host; 3.注意问题 ...

  8. js获取URL中的参数

    js获取URL中的一些参数的意思 location对象 含有当前URL的信息. 属性 href 整个URL字符串. protocol 含有URL第一部分的字符串,如http: host 包含有URL中 ...

  9. nodejs获取当前url和url参数值

    //需要使用的模块 http   url 当前url   http://localhost:8888/select?aa=001&bb=002 var http = require('http ...

随机推荐

  1. Linux 系统常用命令汇总(四) 程序和资源管理

    程序和资源管理 分类 命令 选项 注解 背景管理 & command+& 将任务放到后台进行 ctrl+z 暂停任务 fg [%number] 讲后台程序推到前台来,number表示进 ...

  2. iOS使用Core Graphics和UIBezierPath绘画

    通过UIView的子类的- (void)drawRect:(CGRect)rect 函数可用对视图进行重新绘画: 要重新绘画可以通过Core Graphics和UIBezierPath来实现. 1.通 ...

  3. dalvik

    Google公司自己设计用于Android平台的Java虚拟机

  4. Jenkins学习六:修改Jenkins用户的密码

    很多时候在使用jenkins的时候忘记密码了,遇到这种情况,可以看看下面的讲解. Jenkins专有用户的数据存放在JENKINS_HOME/users目录.users目录的结构你一看就懂.users ...

  5. C# 小型资源管理器

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  6. Java中的Random()函数

    今天在做Java练习的时候注意到了Java里面的一个随机函数——Random,刚开始只是知道这个函数具有随机取值的作用,于是上网搜索了资料一番,做了一下一些关于Random函数的总结:   Java中 ...

  7. [win]AD域组策略wifi自动配置

    http://wenku.baidu.com/link?url=MC950wliAZNeVUJ2M6Y1VTi5faqo7kG374fyBjW57r0qyLJkBZLg5ypiql4RFywQ8q7y ...

  8. yield(C# 参考)

    yield(C# 参考) 在语句中使用 yield 关键字,表示在该关键字所在的方法.运算符或 get 访问器是迭代器.   通过使用 yield 定义迭代器,可在实现自定义集合类型的 IEnumer ...

  9. Toolbar的使用

    项目来源: https://github.com/xuwj/ToolbarDemo#userconsent# 一.V7包升级问题 折腾好久,终于解决 <style name="AppT ...

  10. SVM+HOG特征训练分类器

    #1,概念 在机器学习领域,支持向量机SVM(Support Vector Machine)是一个有监督的学习模型,通常用来进行模式识别.分类.以及回归分析. SVM的主要思想可以概括为两点:⑴它是针 ...