Javascript 在页面加载时生成二维码

Javascript 在页面加载时生成二维码,javascript,qr-code,Javascript,Qr Code,所以我尝试在页面加载时生成一个二维码,这样人们就不必在手机上浏览我的网站就能看到一个页面。我的密码是: <script> function process() { var url=" https://api.qrserver.com/v1/create-qr-code/?size=150x150&data==" + window.location.href; } </script> <body onload="process()"> </body

所以我尝试在页面加载时生成一个二维码,这样人们就不必在手机上浏览我的网站就能看到一个页面。我的密码是:

<script>
function process()
{
var url=" https://api.qrserver.com/v1/create-qr-code/?size=150x150&data==" + window.location.href;
}
</script>
<body onload="process()">
</body>

函数过程()
{
变量url=”https://api.qrserver.com/v1/create-qr-code/?size=150x150&data==“+window.location.href;
}
我不太确定我在这件事上哪里出了问题?如果有人能指出错误就好了


谢谢

您可能正在生成二维码,但没有显示,您需要将图像放在页面上的某个位置-以下只是一个指南

<script>
function process()
{
   var url=" https://api.qrserver.com/v1/create-qr-code/?size=150x150&data==" + window.location.href;
   document.getElementById('QRCode').src = url;
}
</script>
<body onload="process()">
   <img src='' id='QRCode' ...>
</body>

函数过程()
{
变量url=”https://api.qrserver.com/v1/create-qr-code/?size=150x150&data==“+window.location.href;
document.getElementById('QRCode').src=url;
}