从当前页面的位置解析锚点的最简单方法是什么? [英] What's the easiest way to parse the anchor out of the current page's location?

查看:67
本文介绍了从当前页面的位置解析锚点的最简单方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在JavaScript中使用 window.location 来锚定锚点,例如以下网址:

I need to the anchor out of a window.location in JavaScript, such as the following url:

http://www.example.com/page.html#anchor1

什么是最简单的方法?

推荐答案

window.location.hash

这篇关于从当前页面的位置解析锚点的最简单方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆