Take the 2-minute tour ×

I would like to restrict users from my website to stop redirection to another website. For example my website is www.paktutorial.com and there is a link to website www.google.com. but i want that user do not navigate to google.com ( I want that link over there but do not the redirection).

Thanks in advance.

share|improve this question
Why dont you disable the link. Show the link but disable them. –  Abhishek Saha Oct 28 '12 at 7:40
that's not possible. It is something coming out of jquery really complex code and written by someone else. I tried many things but not working. just I would like to stop navigation. –  محمد خليل Oct 28 '12 at 7:44
I understand it might be complex. But if you want to disable them, its just 2 lines of code. –  Abhishek Saha Oct 28 '12 at 8:37
add comment

2 Answers

This is what I understood from your question.



<a href="www.google.com">link 1</a>
<a href="www.paktutorial.com">link 2</a>


$('a').on("click", function(e){

So basically I would look in the window's URL and see if the target URL of the anchor tag clicked has the same host, and if not, prevent the window from redirecting.​

share|improve this answer
add comment

As a solution to your problem please refer the below HTML code snippet . You need to define anchor tag in following manner.

  <a href="javascript:void(0);">link</a>

Specifying javascript:void(0) in href property of anchor element will prevent its default behaviour since void operator returns null as a result of which browser will not be able to load new page.

For more documentation about javascript:void(0) please refer the documentation mentioned in below url http://www.tizag.com/javascriptT/javascriptvoid.php

share|improve this answer
add comment

Your Answer


