javascript - href does not work when link returned from function -
the following works:
<a id="showdirectionsmaplink" href="#" onclick="href='comgooglemaps://maps.google.com/maps?saddr=google,+1600+amphitheatre+parkway,+mountain+view,+ca+94043&daddr=google+inc,+345+spear+street,+san+francisco,+ca¢er=37.422185,-122.083898&zoom=10';">test</a>
it opens in google maps app.
the following not work:
<a id="showdirectionsmaplink" href="#" onclick="showdirectionsmap();">test2</a>
showdirectionsmap() function location of accounts selected , return same exact string above. href='comgooglemaps://maps.google.com/maps?saddr=google,+1600+amphitheatre+parkway,+mountain+view,+ca+94043&daddr=google+inc,+345+spear+street,+san+francisco,+ca¢er=37.422185,-122.083898&zoom=10'
nothing happens
if want url returned function used, have assign this.href
, did in version used literal string.
<a id="showdirectionsmaplink" href="#" onclick="this.href = showdirectionsmap();">test2</a>
Comments
Post a Comment