kragor kragor - 3 months ago 8
HTML Question

syntax error: missing ) after the arguement list?

<button id="btn" onclick="download(http://imageurl) value ="download"><button>


<script>
function download(url){
console.log(url);
var link = document.createElement('a');
link.href = url;
link.download = "image.jpg";
document.body.appendChild(link);
link.click();}
</script>


Synatx error ) missing after the arguement list?

Answer

You are missing quotes in the HTML. Both the close " for the onclick attribute, and you need to wrap your parameter in single quotes to make it a string:

<button id="btn" onclick="download('http://imageurl')" value ="download"><button>