有个投诉说页面变形了,一问才知道页面被用户不小心zoom了,这个情况最好是能对用户有个提示。写了个IE和firefox下检测zoom的demo:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > <HTML > <BODY > <div id ="output" ></div > <SCRIPT LANGUAGE ="JavaScript" > ( function (){ window.onresize = testZoom; var _screenOriginalWidth = window.screen.width function testZoom(){ if (window.screen.width < _screenOriginalWidth){ document.getElementById("output").innerHTML = " <br>Zoom In " ; } if (window.screen.width > _screenOriginalWidth){ document.getElementById("output").innerHTML = " <br>Zoom Out " ; } _screenOriginalWidth = window.screen.width } })() </SCRIPT> </BODY> </HTML>