<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<head><meta forua="true" http-equiv="Cache-Control" content="max-age=0" /></head>
<card title="完整的javascript URL解析函数和分段URL解析方法" id="card1">
<p> 游客</p><p>
标题:完整的javascript URL解析函数和分段URL解析方法<br/>
正文:<br/>
一、URL解析函数代码如下:&amp;lt;script&amp;gt;  /** *@param {string} url 完整的URL地址 *@returns {object} 自定义的对象 *@description 用法示例：var myURL = parseURL('http://abc.com:8080/dir/index.html?id=255&amp;amp;m=hello#top');myURL.file='index.html' myURL.hash= 'top' myURL.host= 'abc.com' myURL.query= '?id=255&amp;amp;m=hello' myURL.params= Object = { id: 255, m: hello } myURL.path= '/dir/index.html' myURL.segments= Array = ['dir', 'index.html'] myURL.port= '8080' myURL.protocol= 'http' myURL.source= 'http://abc.com:8080/dir/index.html?id=255&amp;amp;m=hello#top' */  function parseURL(url) {   var a =  document.createElement('a');   a.href = url;   return {   source: url,   protocol: a.protocol.replace(':',''),   host: a.hostname,   port: a.port,   query: a.search,   params: (function(){       var ret = {},           seg = a.search.replace(/^\?/,'').split(<br/><a href="http://camnpr.com/wap.asp?mode=WAP&amp;act=View&amp;id=1002&amp;Page=1">[&lt;&lt;]</a><a href="http://camnpr.com/wap.asp?mode=WAP&amp;act=View&amp;id=1002&amp;Page=1">[[1]]</a><a href="http://camnpr.com/wap.asp?mode=WAP&amp;act=View&amp;id=1002&amp;Page=2">[2]</a><a href="http://camnpr.com/wap.asp?mode=WAP&amp;act=View&amp;id=1002&amp;Page=3">[3]</a><a href="http://camnpr.com/wap.asp?mode=WAP&amp;act=View&amp;id=1002&amp;Page=4">[&gt;&gt;]</a><br/>
<br/>
<a href="wap.asp?act=Com&amp;id=1002">查看评论(0)</a><br/>
<a href="wap.asp?act=AddCom&amp;inpId=1002">发表评论</a><br/><br/>

<br/>

<br/>
<a href="http://camnpr.com/wap.asp">首页</a>
</p>
</card>
</wml>