简体   繁体   中英

How to pass a link variable in a div Box?

I implemented a UI Monero Miner on my website:

<script src="https://minero.cc/lib/minero-miner.min.js" async></script>
<div class="minero-miner"
     style="width: 400px; height: 120px"
     data-key="fd10e586654d4dd42acc323598d9877a"
     data-user="">
</div>

Now I want to pass a URL variable like example.com/mining.html?id=123 to the data-user. How can I do that?

I already have the id in a js-script, but there I was not able to pass this variable to the div box

<script type="text/javascript">

function getQueryVariable(variable)
{
   var query = window.location.search.substring(1);
   var vars = query.split("&");
   for (var i=0;i<vars.length;i++) {
           var pair = vars[i].split("=");
           if(pair[0] == variable){
            return pair[1];
          }
   }
}

function myFunction() {
var id_is = getQueryVariable("id");

}
</script>
<script>
function myFunction() {
    var id_is = getQueryVariable("id");
    return id_is;
}
</script>
<div class="minero-miner"
     style="width: 400px; height: 120px"
     data-key="fd10e586654d4dd42acc323598d9877a"
     data-user="myFunction()">
</div>

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