Javascript examples for DOM HTML Element:Anchor
Using setAttribute('href') to set link for <a>
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){/* ww w . j a v a 2 s. c om*/ var o = document.getElementById("LinkFBShareLink"); var link = "foo"; var title = "bar"; var fbURL = 'https://www.facebook.com/sharer/sharer.php?u=' + link + '&title=' + title; o.setAttribute('href', fbURL); } </script> </head> <body> <a href="#" id="LinkFBShareLink">testing</a> </body> </html>