C语言 c++ php mysql nginx linux lnmp lamp lanmp memcache redis 面试 笔记 ppt 设计模式 问题 远程连接

javascript 解析url

方式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

 

 

方式3: 

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

 

参考文章:http://www.nowamagic.net/javascript/js_GetUrl.php

posted on 2012-11-09 01:16  思齐_  阅读(1133)  评论(0编辑  收藏  举报