Share anchor links

2019-02-18 23:38发布

问题:

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