How put a variable in a link

2020-05-10 12:02发布

i have this link and this variable:

var fin = "SAT000000002574";
"http://sat3.altervista.org/index.php?id='+fin'"

I don't know how i have to write this link. I have syntax problem. I tried but the link is ever wrong. Help me

3条回答
混吃等死
2楼-- · 2020-05-10 12:39

Interpolation is not standard in javascript. Maybe this can help you http://www.diveintojavascript.com/projects/javascript-sprintf

Contatination is your best option, but the methods below can also help.

String.concat();

["foo", "bar"].join("");
查看更多
▲ chillily
3楼-- · 2020-05-10 12:54

You can just simply using a + to concatenate the fin variable here:

var fin = "SAT000000002574";
"http://sat3.altervista.org/index.php?id="+fin
查看更多
贼婆χ
4楼-- · 2020-05-10 12:58

youre mixing double quotes with single quotes

 "http://sat3.altervista.org/index.php?id="+fin
查看更多
登录 后发表回答