URL pathname 屬性
pathname 屬性返回或設定當前 url 的路徑,以斜槓 / 開頭。
關於URL 物件知識參閱 URL 物件 一章節。
語法結構:
[JavaScript] 純文字檢視 複製程式碼string = url.pathname; url.pathname = string;
程式碼例項:
[JavaScript] 純文字檢視 複製程式碼執行程式碼let url = new URL("https://www.softwhy.com/ant/article-9301-1.html"); console.log(url.pathname);
程式碼執行效果截圖如下:
pathname 屬性返回當前 url 的路徑部分。
[JavaScript] 純文字檢視 複製程式碼執行程式碼let url = new URL("https://www.softwhy.com/ant/article-9301-1.html"); url.pathname = "/a/b/index.html"; console.log(url.pathname); console.log(url.href);
程式碼執行效果截圖如下:
可讀寫屬性,也就是可以重新設定當前 url 的路徑。
相關文章
- 連結a物件的pathname屬性物件
- URL hostname 屬性
- URL password 屬性
- URL hash 屬性
- URL href 屬性
- URL protocol 屬性Protocol
- URL searchParams 屬性
- URL username 屬性
- URL search 屬性
- URL port 屬性
- URL host 屬性
- URL origin 屬性
- 在url中通過屬性名獲取屬性值
- iOS動畫 屬性屬性解析iOS動畫
- CSS 屬性篇(七):Display屬性CSS
- JavaScript私有屬性和靜態屬性JavaScript
- CSS字型屬性和文字屬性詳解CSS
- 私有屬性
- allowfullscreen 屬性
- background 屬性
- cssText 屬性CSS
- translucent屬性
- parentStyleSheet屬性
- cssRules 屬性CSS
- background屬性
- jQuery 屬性jQuery
- 屬性動畫動畫
- jQuery屬性jQuery
- TextView屬性TextView
- XML屬性XML
- Property屬性
- Python - 物件導向程式設計 - 公共屬性、保護屬性、私有屬性Python物件程式設計
- Error 1: Filename must be either an absolute pathname or blocklist(轉)ErrorBloC
- CAD屬性編輯操作——物件屬性教程物件
- WPF 之 依賴屬性與附加屬性(五)
- jQuery設定disabled屬性與移除disabled屬性jQuery
- Python 類的屬性與例項屬性Python
- python物件屬性管理(2):property管理屬性Python物件