[英]Can local javascript variables be read by user console?
我正在嘗試創建一個在線彩票系統,其中用戶必須猜測一個介於1到10之間的數字。如果該數字與javascript生成隨機數匹配,那么他將贏得彩票。 我使用的方法是:
!function(){ var x = Math.floor((Math.random() * 10)); var btn = document.getElementById("btn"); btn.addEventListener("click", function(){ var user_input = document.getElementById("text").value; if( user_input == x) { alert("Won Lottery", user_input, x); } else { alert(user_input + x + "sorry"); } }); }();
<h2>Guess a number between 1 and 10 </h2> <input id="text" type="text"> <button id="btn" type="submit">Submit</button>
我的問題是,黑客可以打開js控制台並以某種方式找到本地x
變量的值嗎?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.