Reputation: 29
my popup link
<a href="javascript:void(0);" onclick="popup('example.com/info?1234', 'PopupWindowCenter')">LINK</a>
I need add a variable to the popup link
var code01=1234;
document.write("<a href=onclick='popup(example.com/info/+code01+)', 'PopupWindowCenter')">LINK</a>")
sorry for any problem or anything. thanks for all
Upvotes: 0
Views: 181
Reputation: 3550
If you want to support older versions of JS without template literals, try
document.write("<a href=onclick='popup(example.com/info/"+code01+")', 'PopupWindowCenter')">LINK</a>")
Upvotes: 0
Reputation: 1
You can use template literal
<script>
function popup(a, b) {
console.log(a, b)
}
</script>
<script>
var code01 = 1234;
document.write(`<a href="#" onclick="popup('example.com/info/${code01}', 'PopupWindowCenter')">LINK</a>`)
</script>
Upvotes: 1