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

相关文章:

  • 2022-12-23
  • 2021-11-04
  • 2021-10-13
  • 2021-11-03
  • 2022-02-18
  • 2022-12-23
猜你喜欢
  • 2021-08-16
  • 2022-12-23
  • 2021-12-02
  • 2022-02-03
  • 2021-11-30
  • 2022-12-23
相关资源
相似解决方案