html获得当前页面路径

html-css06

html获得当前页面路径,第1张

要使HTML获得路径,肯定是要用到JavaScript,获得方式有以下几种方式 获得方式都是 window.location. = this.location.在后边加入要获得的方式,这里我就以this.location.方式说一下 加入当前页面的全路径是 http://127.0.0.1:8020/login/getUrl.html?__hbt=1523851552803另外还有 url = window.location.hash/* 获取锚点(“#”后面的分段) / alert(url)/ #test?name=test */

var

box=document.getElementById('box')

//

获取元素

alert(box.getBoundingClientRect().top)

//

元素上边距离页面上边的距离

alert(box.getBoundingClientRect().right)

//

元素右边距离页面左边的距离

alert(box.getBoundingClientRect().bottom)

//

元素下边距离页面上边的距离

alert(box.getBoundingClientRect().left)

//

元素左边距离页面左边的距离

getBoundingClientRect()

---元素距离页面的距离

canvas--详情参考css3(画图用的)

clientX--鼠标位置的x轴坐标

var

xe应该就是一个变量

3.获取在canvas里的点坐标

getBoundingClientRect()//用于获取某个元素相对于视窗的位置集合。集合中有top,

right,

bottom,

left等属性。

function

detect(event){

var

x=event.clientX-canvas.getBoundingClientRect().left

var

y=event.clientY-canvas.getBoundingClientRect().top

}

综合上述应该是获取在canvas里的点坐标吧!

http://blog.csdn.net/gao_xu_520/article/details/59484428

你好 获取HTML代码可以单机鼠标右键,选择查看网页源代码就可以看到HTML代码了,不过有的代码可能是后端生成的

不过这种方式不能查看JS动态生成的代码,如果要查看的话可以直接案F12,也可以查看代码

希望我的回答能够帮助到你,如果还有什么疑问欢迎继续追问。