简体   繁体   中英

get URL from ID

So i'm using http://goqr.me/ 's API to generate QR codes for download links on my site so people can download things straight to their mobile.

However the user can only Input the download link to a button as the QRcode is hard coded into the site, so i was wondering if it's possible to grab the URL of the button they generate and add it into the API of the QRcode generator.

I'm probably better off using javascript instead of the html API i'm using but i'm not very good with javascript.

some example code:

user submitted download button:

<a href="http://www.example.com" id="QRcode">Download</a>

QRcode:

<img src="https://api.qrserver.com/v1/create-qr-code/?data= #QRcode URL &size=115x115">

HTML part:

<a href="http://www.example.com" id="QRcode" onclick="generateQrDownload(); return false;">Download</a>
<img id="qrImg" src="http://my_initial_url">

By using javascript you could grab the value from the input field and append to your url by using the following function in javascript

function generateQrDownload() {
    var url = 'https://api.qrserver.com/v1/create-qr-code/?data=' + document.getElementById('QRcode').href+ '&size=115x115';
    document.getElementById('qrImg').src = url;
}

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM