html url地址解析
通过JavaScript的location对象,可获取URL中的协议、主机名、端口、锚点、查询参数等信息。
示例
URL:http://www.akmsg.com/WebDemo/URLParsing.html#top?username=admin&pwd=123456
解析结果:
立即学习“前端免费学习笔记(深入)”;
代码
console.log( 'location.hash :' + location.hash + '\r\n' + 'location.host :' + location.host + '\r\n' + 'location.hostname :' + location.hostname + '\r\n' + 'location.href :' + location.href + '\r\n' + 'location.pathname :' + location.pathname + '\r\n' + 'location.port :' + location.port + '\r\n' + 'location.protocol :' + location.protocol + '\r\n' + 'location.hash :' + location.hash + '\r\n' + 'location.search :' + location.search + '\r\n' + 'location.origin :' + location.origin )
在线示例
HTML怎么学习?HTML怎么入门?HTML在哪学?HTML怎么学才快?不用担心,这里为大家提供了HTML速学教程(入门课程),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号