乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      jQuery插件之-jQuery URL Parser $.url.attr('path')

       CevenCheng 2012-05-24
      jQuery插件之-jQuery URL Parser
      發(fā)表于625 天前 JavaScriptjQuery 暫無評論 ? 被圍觀 707 views+

      jQuery插件Query URL Parser用于解析URLs字符串。通過它我們可以方便地獲取協(xié)議、主機(jī)、端口、查詢參數(shù)、文件名、路徑等等。在一些靜態(tài)頁面需要根據(jù)參數(shù)來調(diào)整一些內(nèi)容的時(shí)候這個(gè)插件還是挺有用的。

      官方下載(托管在github):http://github.com/allmarkedup/jQuery-URL-Parser

      本地下載地址:jQuery-URL-Parser

      插件可以返回的數(shù)據(jù)有下面幾項(xiàng):

      1 、來源 – URL本身

      2 、協(xié)議 – 例如 HTTP,HTTPS,文件等

      3 、主機(jī) – 如 blog.,localhost 等

      4 、端口 – 例如 80

      5 、查詢 – 如果它存在的話是整個(gè)查詢字符串,例如item=value&item2=value2

      6 、單個(gè)查詢字符串參數(shù)值

      7 、文件 – 該文件名,例如 index.html的

      8 、錨 – 哈希(錨)值

      9 、路徑 – 文件的路徑(如/folder/dir/index.html)

      10 、相對路徑- 包括查詢字符串的相對路徑(如/folder/dir/index.html?item=value)

      11 、目錄 – 目錄路徑(如/folder/dir/)

      12 、路徑的個(gè)別部分

      如果需要獲取上面的 1、2、3、4、7、8、10、11 項(xiàng)的值可以通過使用 .attr() 方法來獲取。

      6項(xiàng)可以使用 .param() 方法。

      12項(xiàng)可以使用 .segment() 方法。

      使用DEMO:

      1,使用當(dāng)前頁面的URL(假如地址是http://blog./information/about/index.html?itemID=2&user=dave)

      01// get the protocol
      02jQuery.url.attr("protocol"// returns 'http'
      03 
      04// get the path
      05jQuery.url.attr("path"// returns '/information/about/index.html'
      06 
      07// get the host
      08jQuery.url.attr("host"// returns 'blog.'
      09 
      10// get the value for the itemID query parameter
      11jQuery.url.param("itemID"// returns 2
      12 
      13// get the second segment from the url path
      14jQuery.url.segment(2) // returns 'about'

      2,使用其他指定的URL

      1// set a different URL and return the anchor string
      2jQuery.url.setUrl("http://blog./category/javascript/#footer").attr("anchor") // returns 'footer'

      今天使用發(fā)現(xiàn)了一個(gè)小小的 bug ,如果 URL 為 “/product?&typeId=67&ppath=15:31;14:14” , 那么這時(shí) jQuery.url.param('typeId')  則返回 undefind 

        本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評論

        發(fā)表

        請遵守用戶 評論公約

        類似文章 更多