web前端|js教程
nodejs,url地址,参数值
web前端-js教程
源码是什么样子的,vscode启动设备失败,ubuntu 鼠标,netty tomcat,sqlite3使用教程,app制作好的网页设计,exp导出本地数据库,阿里云 关系型服务器,ecshop尺码颜色插件,前端经常使用的框架,爬虫调度端,php count,快速提升排名seo,springboot坐标,html标签对SEO影响,手工写的源码网站排名,网页轮显幻灯片,内容网站模板,html5 带后台,单页面网站制作视频,正方教务管理系统 源码,微信小程序 餐饮源码lzw
//需要使用的模块 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: 01, bb: 02 }
console.log(arg.aa);//返回001
console.log(arg.bb);//返回002
//然后就可以根据所得到的数据处理了
易语言com_注册类型库源码,ubuntu安装优先启动,tomcat发信息给客户端,爬虫怎么翻身最快,php如何替换a.b的值,搜网站seolzw
}).listen(8888);//建立服务器并监听端口
线下任务源码,ubuntu方向隧道配置,学蛆爬虫子,aspx php html,SEO技巧组合lzw
获取特定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: 01}这样的对象, 直接打印p.query则返回 [object Object],这时我们可以这样 写: console.log(p.query.aa); //取到的值是:001
console.log( p.pathname);//取到的值是:/select
下面附上js的获取方法:
当前URL
/index.php?aa=001&bb=002
document.location: /index.php?aa=001&bb=002
document.URL: /index.php?aa=001&bb=002
document.location.href: /index.php?aa=001&bb=002
self.location.href: /index.php?aa=001&bb=002
top.location.href: /index.php?aa=001&bb=002
parent.document.location: /index.php?aa=001&bb=002
top.location.hostname:
location.hostname: