您的位置:首页 > Web前端 > JavaScript

javascript 解析url

2012-11-09 01:16 375 查看
方式1:

<script>
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";

parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port;     // => "3000"
parser.pathname; // => "/pathname/"
parser.search;   // => "?search=test"
parser.hash;     // => "#hash"
parser.host;     // => "example.com:3000"

</script>


方式2:

http://code.google.com/p/jsuri/downloads/list



[b]方式3: [/b]

http://medialize.github.com/URI.js/

参考文章:http://www.nowamagic.net/javascript/js_GetUrl.php
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: