开发者

Ajax # and scroll-to #

开发者 https://www.devze.com 2023-02-19 08:56 出处:网络
Is it possible to have both an \"AJAX\" hash mark # as well开发者_StackOverflow as a scroll down to one?

Is it possible to have both an "AJAX" hash mark # as well开发者_StackOverflow as a scroll down to one?

Thanks.


No.

The # is a special character in a URL, it marks the rest of the URL as a fragment identifier, so everything after it refers to an HTML element id, or a named anchor in the current page. (Source)

What's the shebang/hashbang (#!) in Facebook and new Twitter URLs for? - it's only for Googlebot.

Yes.

If you really want to have both, the scroll-to bit can be fudged width JavaScript. It wouldn't be pretty.


As far as I know, # is not allowed in a fragment identifier. You could encode it as %23 and do something with that maybe.

If you're doing on-page stuff that you would like to be able to scroll to, you could just hijack links by adding a certain class to them or something.

Also, consider reading up on history.pushState and such on:

https://developer.mozilla.org/en/DOM/Manipulating_the_browser_history

0

精彩评论

暂无评论...
验证码 换一张
取 消