我在我的网站上实现了UI Monero Miner:
<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>
现在,我想将example.com/mining.html?id=123
之类的URL变量传递给数据用户。我该怎么办?
我已经在js脚本中包含了ID,但是我无法将此变量传递给div框
<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>
答案 0 :(得分:0)
<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>