Saturday 29 April 2017

Show user a different location and send it to another

Many people have a habit to check the link before going on it.How they check it? Yes! by keeping mouse on it.When you brought mouse cursor over the link , the browser will show you where the link goes.


browser showing same url for the link

Even you can try also when I keep muse over any link browser shows me that original link only.But now , when I click over the link it takes me to another link and then redirect me from that page.You can try by dragging the link and then re hovering on it. But how this is possible?You have ever thought about it that many affiliate links also does that.Many people hovers over an link or an image to get a idea about the normal and affiliate link.But they fails.



Now if you to want to do this , you're on the right place.But before that let's find out what is the mechanism behind it.

THE MARKUP : 1st way
There can be many ways to do it ,I mentioned here two.First way is to set onclick event in JavaScript.When this event is fired , the page goes to another page.


<a href="css-magz.blgspot.com" onclick="this.href='http://css-magz.blogspot.com/2017/04/show-user-different-location-and-send.html'">hey!Click here!</a>

The result is shown below-
hey!

You can also implement it on the images and that you already know.

Second Way
The noticeable thing in the above way is when the user directly drag and drop the link in the new browser window , your main link won't be work.And the solution fore that is here.

Here we are going to use onmousedown event.By using , our problem will solve.



<a id="myP" href="https://hmm.com" onmousedown="mouseDown()">
Click here!don't worry you'be not redirected to hmm.com
</a>

<script>
function mouseDown() {
    document.getElementById("myP").href = "https://css-magz.blogspot.com";
}
</script>

The above code will show normal URL to hmm.com but when drag or click it will change it to css-magz.blogspot.com. The result of above code is here.

Click here!don't worry you'be not redirected to hmm.com

Thanks for reading this article,make sure you have followed our blog.If not, follow now! it is completely free and takes no longer than 1 minute!

0 Please Share a Your Opinion.:

Comment something useful and creative :)