JS 使用Unicode编码向控制台输出信息

<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<script>
try {
	if(window.console && window.console.log) {
		console.log("\u4e00\u7ad9\u5f0f\u7f51\u7edc\u000d\u000a");
		console.log("\u9605\u8c01\u95ee\u541b\u8bf5\uff0c\u6c34\u843d\u6e05\u9999\u6d6e");
		console.log("\u90ae\u7bb1\u003a %c\u006f\u006e\u0065\u0073\u0074\u006f\u0070\u0077\u0065\u0062\u0040\u0031\u0036\u0033\u002e\u0063\u006f\u006d","color: blue ")
	}
}catch(e){};
</script>
</body>
</html>

Unicode编码转换的网址:http://tool.chinaz.com/tools/unicode.aspx  打开链接

PS:很多的网站是通过这种方式来推广一些信息,但又让别人很难找到出处。算是一种小技巧吧。

效果图:

 

猜你喜欢

转载自onestopweb.iteye.com/blog/2327888