Eclispe 导入Web项目,在Eclipse打开正常,运行到浏览器乱码。
Eclispe打开:
(function () {
var a_idx = 0;
window.onclick = function (event) {
var a = new Array("❤富强❤", "❤民主❤", "❤文明❤", "❤和谐❤", "❤自由❤", "❤平等❤", "❤公正❤", "❤法治❤", "❤爱国❤", "❤敬业❤", "❤诚信❤", "❤友善❤");
var heart = document.createElement("b"); //创建b元素
heart.onselectstart = new Function('event.returnValue=false'); //防止拖动
document.body.appendChild(heart).innerHTML = a[a_idx]; //将b元素添加到页面上
a_idx = (a_idx + 1) % a.length;
heart.style.cssText = "position: fixed;left:-100%;"; //给p元素设置样式
var f = 16, // 字体大小
x = event.clientX - f / 2, // 横坐标
y = event.clientY - f, // 纵坐标
c = randomColor(), // 随机颜色
a = 1, // 透明度
s = 1.2; // 放大缩小
var timer = setInterval(function () { //添加定时器
if (a <= 0) {
document.body.removeChild(heart);
clearInterval(timer);
} else {
heart.style.cssText = "font-size:16px;cursor: default;position: fixed;color:" + c + ";left:" + x + "px;top:" + y + "px;opacity:" + a + ";transform:scale(" + s + ");";
y--;
a -= 0.016;
s += 0.002;
}
}, 15)
}
// 随机颜色
function randomColor() {
return "rgb(" + (~~(Math.random() * 255)) + "," + (~~(Math.random() * 255)) + "," + (~~(Math.random() * 255)) + ")";
}
}());
function click(){
if(event.button==2){
alert('对不起,网页右键已被禁用!');
}
}
document.onmousedown=click
运行到浏览器:
(function () {
var a_idx = 0;
window.onclick = function (event) {
var a = new Array("鉂ゅ瘜寮衡潳", "鉂ゆ皯涓烩潳", "鉂ゆ枃鏄庘潳", "鉂ゅ拰璋愨潳", "鉂よ嚜鐢扁潳", "鉂ゅ钩绛夆潳", "鉂ゅ叕姝b潳", "鉂ゆ硶娌烩潳", "鉂ょ埍鍥解潳", "鉂ゆ暚涓氣潳", "鉂よ瘹淇♀潳", "鉂ゅ弸鍠勨潳"); var heart = document.createElement("b"); //鍒涘缓b鍏冪礌
heart.onselectstart = new Function('event.returnValue=false'); //闃叉鎷栧姩
document.body.appendChild(heart).innerHTML = a[a_idx]; //灏哹鍏冪礌娣诲姞鍒伴〉闈笂
a_idx = (a_idx + 1) % a.length;
heart.style.cssText = "position: fixed;left:-100%;"; //缁檖鍏冪礌璁剧疆鏍峰紡
var f = 16, // 瀛椾綋澶у皬
x = event.clientX - f / 2, // 妯潗鏍�
y = event.clientY - f, // 绾靛潗鏍�
c = randomColor(), // 闅忔満棰滆壊
a = 1, // 閫忔槑搴�
s = 1.2; // 鏀惧ぇ缂╁皬
var timer = setInterval(function () { //娣诲姞瀹氭椂鍣�
if (a <= 0) {
document.body.removeChild(heart);
clearInterval(timer);
} else {
heart.style.cssText = "font-size:16px;cursor: default;position: fixed;color:" + c + ";left:" + x + "px;top:" + y + "px;opacity:" + a + ";transform:scale(" + s + ");";
y--; a -= 0.016; s += 0.002; } }, 15)
} // 闅忔満棰滆壊
function randomColor() {
return "rgb(" + (~~(Math.random() * 255)) + "," + (~~(Math.random() * 255)) + "," + (~~(Math.random() * 255)) + ")"; } }());
function click(){ if(event.button==2){ alert('瀵逛笉璧凤紝缃戦〉鍙抽敭宸茶绂佺敤锛�'); } }
document.onmousedown=click
修改过Tomcat中的server.xml、web.xml、catalina.bat,Eclipse中的Preferences > General,均无效。以前在旧电脑成功运行过,换到新电脑出现乱码。新电脑按照原来旧电脑配置的版本进行配置。