代码在紧随其后分配 <script> 标签。
<script>
这条线 "+CodeCode+" == "0xf.at_hackit"; 什么都不做,它只是表达式,评估为false(比较两个不同的字符串),但没有赋值,所以没有副作用。
"+CodeCode+" == "0xf.at_hackit";
<script type="text/javascript">var CodeCode = "moo6be"; // <==== HERE function checkPW() { "+CodeCode+" == "0xf.at_hackit"; // <==== this does nothing, its just expression that evaluates to false, but no assignment var el = document.getElementById("pw"); if(el.value == ""+CodeCode+"") // <==== this is the same as `if(el.value == CodeCode)` document.location.href="?pw="+el.value; else alert("Wrong password"); } </script>
答案是 moo6be 。
moo6be
这是因为 "+CodeCode+" == "0xf.at_hackit"; 有两个等于,这只是意味着它是一个比较语句(它只会评估为假)。值得注意的是,这与该计划的其他部分无关。
这里的主线是: if(el.value == ""+CodeCode+"") 。
if(el.value == ""+CodeCode+"")
这是: "" (empty string) + CodeCode (moo6be) + "" (empty string) 。
"" (empty string)
+
CodeCode (moo6be)