1 <html> 2 <head> 3 <title>你用的盒子模型是?</title> 4 <script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script> 5 <script type="text/javascript"> 6 $(function () { 7 var box = $.support.boxModel == true ? "W3C盒子模型" : "IE盒子模型"; 8 document.write(box); 9 }) 10 </script> 11 </head> 12 <body> 13 <span id="tip"></span> 14 </body> 15 </html>
让IE也使用W3C的盒子模型只需要在<html>前加上如下代码就可以了:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">