php - Change Location of Outgoing Link On Click -


i'm trying link page without displaying real url on hover or in source code. want <a> redirect $newurl; if there url defined in href="".

<?php $newurl = "http://therealurl.com/folder/private.php" ?> <a href="http://domain.com">link</a> 

so using code above want replace http://domain.com <?php echo $newurl; ?> when user clicks on <a> because never want displayed user.

is there solution target specific anchor this? if not every link on page fine want in way real url not displayed privacy reasons.

here solution.

 <?php $newurl = "http://therealurl.com/folder/private.php"; ?>  <script>   $( document ).ready(function(){   $( '#link' ).click(function(){         var newlink = <?php echo json_encode($newurl);?>;         $(this).attr("href", newlink);     });   });  </script>  <a id="link" href="http://domain.com">link</a> 

don't forget include jquery library.


Comments