<head> <script> function go_to(ff) { alert (ff); } </script> </head> <body> <script> var tt = "lol"; document.write("<a href='#' onClick='return go_to(tt);'>"+tt+"</a>"); </script> </body>