Robolisk Robolisk - 1 year ago 85
HTML Question

redirect link from facebook to website - javascript?

I have articles posted on facebook from my website

the website is made in wordpress, and I've also created a "Welome" landing page where I want most new users to be directed too.

I have no idea where I can find information on how to do this, even after countless efforts of googling.

To give an exact idea of what I' trying to create...

Where someone clicks on an article on facebook, it'll take them to the "welcome" sign up page, then have a link on it to the article that they clicked on. The link would change depending on what article they clicked on so they can be redirected properly.

I know I can just hard code it, and create multiple landing pages with different links in relation to the article posted, but this just seems inefficient.

Does anyone know how to go about doing this?

this is the landing page

Answer Source

You can try using Javascript, as it would be much easier than creating several webpages. At the point in your page where you want a link to be placed, put something like

<p id="mynewredirectlink"><a href="">Hey!</a></p>

And then at the bottom of your code, add some javascript to resemble this:

<script type="text/javascript">
if (document.referrer === "")//Where did you come from?
    $("#mynewredirectlink").innerHTML = "<a href="">Hey!</a>"   //Where are you going?

Then include the other sites you need, and close it with


There may be some sites that have varying parts, like an id, so if you need to, you can use (document.referrer.includes("")) instead.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download