html path属性,HTML Location pathname用法及代码示例
生活随笔
收集整理的這篇文章主要介紹了
html path属性,HTML Location pathname用法及代码示例
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
HTML中的Location pathname屬性用于設置或返回URL的路徑名。 Location pathname屬性返回一個表示URL路徑名的字符串。
用法:
它返回路徑名屬性。location.pathname
它用于設置路徑名屬性。location.pathname = path
以下示例程序旨在說明HTML中的Location pathname屬性:
例:
DOM Location pathname Propertyh1 {
color:green;
}
h2 {
font-family:Impact;
}
body {
text-align:center;
}
GeeksforGeeks
DOM Location pathname Property
For returning the path name of the
current URL, double click the "Return
Pathname" button:
Return Pathname
function mypath() {
var p = location.pathname;
document.getElementById("path").innerHTML = p;
}
輸出:
單擊按鈕后:
支持的瀏覽器:以下列出了Location pathname屬性支持的瀏覽器:
谷歌瀏覽器
IE瀏覽器
Firefox
Opera
Safari
總結
以上是生活随笔為你收集整理的html path属性,HTML Location pathname用法及代码示例的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 物价上涨的原因和影响
- 下一篇: html制作柱状图教程,基于Echart