看到這樣一段**:
exports.showlogin = function (req, res) ;
referer就是跳轉到你的**的之前**的url引用
php中可以通過post or get 獲取到url中的引數值,最近接觸了node那麼在nodejs裡是怎麼做的呢,上**了!
//需要使用的模組 http url
當前url http://localhost:8888/select?aa=001&bb=002
console.log(arg.aa);//返回001
console.log(arg.bb);//返回002
//然後就可以根據所得到的資料處理了
}).listen(8888);//建立伺服器並監聽埠
獲取特定url引數值
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則返回的是如:這樣的物件, 直接列印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
獲取url位址列的引數
獲取url位址列的引數 var url window.location.href var index url.substring url.lastindexof 1 1 window.location.href 整個url字串 在瀏覽器中就是完整的位址列 2 window.location.prot...
獲取和新增URL位址列引數
js寫法 var a 1018802,8 var b 1 window.location.href editposts.aspx?postid a update b 2.字串模板,動態生成href屬性 var c 檢視位址 1.只使用split將字串擷取成陣列var url window.locat...
js 獲取url 獲取位址列
設定或獲取物件指定的檔名或路徑。alert window.location.pathname 設定或獲取整個 url 為字串。alert window.location.href 設定或獲取與 url 關聯的埠號碼。alert window.location.port 設定或獲取 url 的協議部分...