Share anchor links

强颜欢笑 提交于 2019-12-01 07:12:08

问题


I want to make a button that shares links in this form:

http://example.com/#anchor

but when i click it, it shares only

http://example.com

How could I make it share what I want?


回答1:


Your question is not very detailed and it's not easy to understand exactly what it is you're asking for..

Since the share functionaliy was deprecated I assume that you are talking about the Like button. As you can see in that page you can put what ever url you want into the "URL to Like" field, then click the "Get Code" button and use that code in your page.

You can put the code in any page, so if your page is: "example.com/#anchor" you can still have the button like "http://example.com" or the other way around.

If however you want the user to like "example.com/#anchor" but when someone clicks on the liked link he will get to "example.com" then it's not possible.




回答2:


This is very simple; your URL string you want to share should be like this: http://www.domain.com/hello.html%23myanchor

The %23 will be transformed by Facebook into a #.




回答3:


I just thought about this (because I have the same problem). My idea is to share a php link with a variable, let's call it 'a' for anchor, which is the anchor without # so that facebook won't remore it. Thus you share the link: http://www.mywebpa.ge/?a=anchor1 Then you just have to recover the value of 'a' with php and add a little script which makes you go to the anchor. I hope it will help you. Regards



来源:https://stackoverflow.com/questions/10570578/share-anchor-links

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!