简体   繁体   中英

Redirecting to a different page when link is opened in browser

I am really confused on how to create this, so please help me out. I have a html page where I have added the meta fields for link preview on facebook and skype. Now what I want is when I share this link on FB or skype, it should show the link preview with the image I have specified in meta and when the user clicks on the link, this link should open in the browser and then redirected to another link which I am sending through my server using a get request?

How can I do that?

So the link should show meta information on preview and redirected to a new page when loaded in browser

<html>
<meta property="og:image" content="http://example.com"/>

<script type="text/javascript">

            function Redirect() {
               window.location="http://www.example2.com";
            }

            Redirect();

      </script>
<body>

</body>
</html>

You can't do this directly because you're sharing a link not a webpage. Clicking a shared link will always redirect you to that link.

You could do this, have your redirect logic in your http://example.com By doing this, the user will land in http://example.com and will be redirected automatically to http://example2.com

I was able to do it, by using window.location="www.example1.com". But I am able to preview only the link on FB but not on whatsapp.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM