2016-08-02 29 views
0

我想在輸出中對此URL進行美化,我該怎麼做?在Javascript中使用URL

var msg = beasts[loc.beast_id] + "! Left "+dateFormat(timeToDespawn, "MM:ss")+" Link " + " https://www.google.com/maps/dir/Current+Location/"+loc.latitude+","+loc.longitude+" "; 

「鏈接」 這個詞應該直接鏈接到這一點:

https://www.google.com/maps/dir/Current+Location/"+loc.latitude+","+loc.longitude+" 

這是可能的,如何?

在此先感謝!

+0

你的輸出是什麼? HTML嗎?安慰?警報?還有別的嗎? – Joe

+0

我輸出它到Slack,Webhook – Mwisho

+0

你是什麼意思「美化這個URL」? – Hydro

回答

0

假設你要輸出到HTML,您將創建您的鏈接是這樣的:

var msg = "<a href='https://www.google.com/maps/dir/Current+Location/" + String(loc.latitude) + "," + String(loc.longitude) + "'>Link</a>"; 

你會用它來輸出到你的HTML頁面:

$('#foo').html(msg); 

Working jsFiddle