Language: HTML
Right Click and Copy-able links that when clicked redirect to an action (MVC)
<!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>
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!)
Report Abuse
Subscribe
Discuss
What's new
What is it
New Snippet
Recent Snippets
My Snippets
Web Code
Search

