A.N*_*lam 5 javascript eval escaping
var input;
// method 1
input = document.getElementById('address').value;
alert(input)
// method 2
eval('input = "'+document.getElementById('address').value+'"')
alert(input)
Run Code Online (Sandbox Code Playgroud)
方法1工作正常,但是当输入换行符并且它表示"未终止的字符串文字"时,方法2不起作用.
无论如何,我需要使用eval存储值.所以请帮助我.