I have code below of an HTML page that includes a JS file. Function d() receives a String of 24 chars, including 3 non-printable chars (ASCII 005) and counts how many characters are included. This number is displayed with an alert().
I really need this to work with Internet Explorer. Any ideas? THANKS
TEST.HTML
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>JavaScript Scripting</title>
</head>
<body>
<script type="text/javascript" charset="utf-8" src="test.js">
</script>
</body>
</html>
TEST.JS
function d(a){return a.length;};
document.write("<script language=\"Javascript\" charset=\"utf-8\">alert(".concat(d("a[NULL]lert(\"He[NULL]llo Worl[NULL]d\");")).concat(");</script>"));
You should to know when IE lost this bytes! But it looks like it miss them exact on split: check if IE returns true on "" == "\". Try to avoid using hack like smth +""
use toString() ( what would you get after 'Infinity' -0
?). Or use var i= 0; while (a.length) { substr(a, 0, 1); i+=1; //...
var i= 0; while (a.length) { substr(a, 0, 1); i+=1; //...
var i= 0; while (a.length) { substr(a, 0, 1); i+=1; //...
no IE to test, but could help.
UPD
As provided by MSDN IE not in standard mode and less then 9 evaluates "\\v" == "v"
as true , so it could be the same with nullchar which causes the string length becomes shorter?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.