1. 程式人生 > >jQuery 獲取當前url各種資訊

jQuery 獲取當前url各種資訊

設定或獲取物件指定的檔名或路徑。
window.location.pathname
例:http://localhost:8086/topic/index?topicId=361
alert(window.location.pathname); 則輸出:/topic/index
設定或獲取整個 URL 為字串。
window.location.href
例:http://localhost:8086/topic/index?topicId=361
alert(window.location.href); 則輸出:http://localhost:8086/topic/index?topicId=361

設定或獲取與 URL 關聯的埠號碼。
window.location.port
例:http://localhost:8086/topic/index?topicId=361
alert(window.location.port); 則輸出:8086

設定或獲取 URL 的協議部分。
window.location.protocol
例:http://localhost:8086/topic/index?topicId=361
alert(window.location.protocol); 則輸出:http:

設定或獲取 href 屬性中在井號“#”後面的分段。
window.location.hash

設定或獲取 location 或 URL 的 hostname 和 port 號碼。
window.location.host
例:http://localhost:8086/topic/index?topicId=361
alert(window.location.host); 則輸出:http:localhost:8086

設定或獲取 href 屬性中跟在問號後面的部分。
window.location.search
例:http://localhost:8086/topic/index?topicId=361
alert(window.location.search); 則輸出:?topicId=361

window.location
屬性                  描述
hash                設定或獲取 href 屬性中在井號“#”後面的分段。
host                 設定或獲取 location 或 URL 的 hostname 和 port 號碼。
hostname      設定或獲取 location 或 URL 的主機名稱部分。
href                  設定或獲取整個 URL 為字串。
pathname      設定或獲取物件指定的檔名或路徑。
port                  設定或獲取與 URL 關聯的埠號碼。
protocol          設定或獲取 URL 的協議部分。
search            設定或獲取 href 屬性中跟在問號後面的部分

相關推薦

jQuery 獲取當前url各種資訊

設定或獲取物件指定的檔名或路徑。 window.location.pathname 例:http://localhost:8086/topic/index?topicId=361 alert(window.location.pathname); 則輸出:/topic/in

.net和js 獲取當前url各種屬性

function bst 服務器 文件系統 計算機 資源定位 正在執行 選項 PE 轉來 假設當前頁完整地址是:http://www.test.com:80/aaa/bbb.aspx?id=5&name=kelli "http://"是協議名 "www.test.c

jquery獲取當前頁面的URL資訊

以前在做網站的時候,經常會遇到當前頁的分類高亮顯示,以便讓使用者瞭解當前處於哪個頁面。之前一直是在每個不同頁面寫方法。工程量大,也不便於修改。一直在想有什麼簡便的方法實現。後來在網上查到可以用獲取當前URL的詳細資訊來判斷。所以收集了JQUERY獲取URL的函式的資料。 設定或獲取物件指定的檔名或路徑。 wi

jquery獲取當前頁面的URL信息

顯示 earch protocol tag .proto http jquer 高亮 post 以前在做網站的時候,經常會遇到當前頁的分類高亮顯示,以便讓用戶了解當前處於哪個頁面。之前一直是在每個不同頁面寫方法。工程量大,也不便於修改。一直在想有什麽簡便的方法實現。

js 獲取當前URL資訊

document.location 這個物件包含了當前URL的資訊 location.host 獲取port號 location.hostname 設定或獲取主機名稱 location.href 設定或獲取整個URL location.port設定或獲取URL的埠號 location.search 設定或獲取

jquery獲取當前頁面urlurl引數的方法

jquery獲取url的函式的資料 1、設定或獲取物件指定的檔名或路徑。 window.location.pathname 例:   http://localhost:8086/topic/index?topicId=361 alert(window.location.pathname); 則輸出:/to

js獲取當前url地址參數中文亂碼問題

length 地址 網上 當前頁 數組 獲得 clas decode log 網上看了一些關於此問題的文章,都說的不清不楚,有些更是亂七八糟,完全沒法看,故此找了一篇能用的,借鑒作為筆記。 //首先獲取到當前頁面的地址欄信息 var url = window.locati

jQuery獲取URL)地址欄參數

location clas -1 cat 地址 func 地址欄 oca url地址 //獲取地址欄參數 //url為空時為調用當前url地址 //調用方法為 var params = getPatams(); function getPa

JS/JQuery獲取當前元素的上一個/下一個兄弟級元素等元素的方法

input logs type ron put 綁定 style wid cti $(function(){ //遍歷獲取的input元素對象數組,綁定click事件 var len = $("input[type=‘file‘]").length;

jQuery獲取地址url中"?"符以及其後的字串

jquery 及其 subst nbsp 問號 nor earch normal ear var url = location.search; if (url.indexOf("?") != -1)//url中存在問號,也就說有參數。 { if (url.su

js jquery獲取當前元素的兄弟級 上一個 下一個元素 jquery如何獲取第一個或最後一個子元素

pre tool 處理 語法 exp iou 元素 dex syn var chils= s.childNodes; //得到s的全部子節點 var par=s.parentNode; //得到s的父節點 var ns=s.nextSbiling; //獲得s的下

JavaScript獲取當前url路徑

不能 多個 document clas dex 主機 script open www 1、假設當前頁完整地址是:http://localhost:61768/Home/Index?id=2 //獲取當前窗口的Url var url = window.location

jquery獲取當前時間比較日期

ret nds minutes div date ets ace 大於 OS //獲取當前時間,格式 2015-09-05 10:00:00.000 function getnowtime() { var nowtime = new

Cocos Creator 獲取當前URL取參數

.get doc 想要 get 字符 字符串處理 lastindex keyword bsp 利用Javascript獲取當前頁的URL,這個問題起來好像很復雜,如果第一次去想這個問題,很多人估計又在琢磨到底又是哪個神一般的Javascript函數。 其實不是,Javasc

jQuery獲取當前元素的其他元素

進行 con 包括 content trac net statistic -m 的區別 jQuery獲取當前元素的其他元素 轉載自:https://blog.csdn.net/weixin_39414369/article/details/811985

laravel 獲取 當前url 的方法, 有的是獲取 全部url 有的只獲取 主頁其他 部分 阿星小棧

  1. 使用 Request 類: $url = Request::getRequestUri(); 2. 使用 $request 物件: public function show(Request $request) { $url = $request->

jquery獲取當前日期

<!DOCTYPE html>   <html lang="zh-CN">  <head>  <meta charset="utf-8">  <

jquery獲取當前日期的前一天

程式碼如下所示,有其他需求,請酌情修改 var default_time = toLongDate(new Date().getTime()-86400000); function toLongDate(m) { var date = new Date(m); return

laravel框架獲取當前url 的方法 阿星小棧

  1. 使用 Request 類: $url = Request::getRequestUri(); 2. 使用 $request 物件: public function show(Request $request) { $url = $request-&

獲取來訪者的各種資訊

轉自:https://blog.csdn.net/l1028386804/article/details/49890455 package com.cdsmartlink.utils.system; import java.io.BufferedReader; import java.io.