CodePaste Logo
New Snippet New Snippet Recent Snippets Recent Snippets My Snippets My Snippets Web Code Search Snippets Search
Sign inor Register
Language: HTML

Right Click and Copy-able links that when clicked redirect to an action (MVC)

384 Views
Copy Code Show/Hide Line Numbers
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Redirect Link Using jQuery</title>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> 
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js"></script>
    <script type="text/javascript">
        
        // Custom Library Function
        var Library = {
            RedirectUserToUri : function (uri) {
                // alert(uri);
                window.location = 'http://localhost/Redirection/RecordViewOfUriAndRedirectUser/?uri=' + uri ;
                return false;
            }
        }
        
        // Setup the links
        $(document).ready(function() {
            var reUri = $(".RedirectUri");
            reUri.click(function() { 
                Library.RedirectUserToUri($(this).attr("href")); 
                return false; 
            });            
        });
    </script>
</head>
<body>
    <div>
        <a class="RedirectUri" href="http://www.google.com">http://www.google.com</a>
    </div>
</body>
</html>
 
by jwwishart
  November 04, 2009 @ 5:34pm
Tags:
Description:
This is a test to see if I could make a link when clicked post back to an action which would then be able to log that the link was clicked (much like google does) yet the user could still right-click the link and copy the correct link!!! (Which google don't allow, instead they give you the redirect link... for reasons that are fairly obvious!)

Add a comment


Report Abuse
brought to you by:
West Wind Techologies



If you find this site useful and use it frequently please consider making a donation to support this free service.
Donate