猿问

将保存代码放在文本框中,然后将变量更改为该保存代码

我回来了,我尝试了一下,但是任何可以帮助的人都不起作用???我已经设置了保存机制。(我必须添加额外的文本,因此这与脚本本身无关)


这是我用来测试保存机制的代码。


<!DOCTYPE html>

<html>

<body>

<button onclick="point();">points</button>

<button onclick="upgrade()">upgrade</button>

<script language="javascript">

var pointcount = 0;

var totalcliks = 0;

var upgrades = 0;

function point() {

pointcount++;

totalcliks++;

}

function upgrade() {

upgrades++;

pointcount--;

}

function load() {

  var testerload = document.getElementById("savecodetextbox").value;

  document.getElementById("saveshow").innerHTML = testerload;

}

var pointcounterclock = setInterval(function() {pointcounter()},100);

    function pointcounter(){

    document.getElementById("points-screen").innerHTML = pointcount+" points";

    document.getElementById("clicktotal").innerHTML = totalcliks+" totalcliks";

    document.getElementById("savecode").innerHTML = totalcliks+"a"+ pointcount+"a"+ upgrades;

    }

let savecode = "1a1a1"; //grab the input for savecode here

let codes = savecode.split("a");

if(codes.length == 3){ //verify the length is correct

    totalcliks = codes[1];

    updates = codes[2];

    pointcount = codes[3];

}

</script>

<h3 id="points-screen"></h3>

<h3 id="clicktotal"></h3>

<h3 id="savecode"></h3>

<textarea name="text_area" id="savecodetextbox" rows="4" cols="40"></textarea> <button onclick="load()">load</button>

<h3 id="saveshow"></h3>

</body>

</html>


LEATH
浏览 151回答 1
1回答
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答