http://www.cnblogs.com/sink_cup/archive/2010/12/16/javascript_screen_width.html
Javascript检测到你的分辨率,字号自动设置
window.onresize
<!--PageBeginHtml Block Begin-->
<script type="text/javascript">
function changeFontSize()
{
var font_size = screen.width / 64 + 'px';
document.body.style.fontSize = font_size;
if(document.getElementById('font_size')==null)
{
var pNode = document.createElement("p");
pNode.id = 'font_size';
document.body.insertBefore(pNode,document.body.childNodes[0]);
}
else
{
pNode=document.getElementById('font_size');
}
pNode.style.cssText = 'margin:0;background:#FFFFE1;border-bottom:1px solid #666666;';
pNode.innerHTML = "Javascript检测到你的分辨率为" + screen.width + 'x' + screen.height + ',' + '字号自动设置为' + font_size;
}
changeFontSize();
window.onresize=function()
{
changeFontSize();
}
</script>
<script type="text/javascript">
function changeFontSize()
{
var font_size = screen.width / 64 + 'px';
document.body.style.fontSize = font_size;
if(document.getElementById('font_size')==null)
{
var pNode = document.createElement("p");
pNode.id = 'font_size';
document.body.insertBefore(pNode,document.body.childNodes[0]);
}
else
{
pNode=document.getElementById('font_size');
}
pNode.style.cssText = 'margin:0;background:#FFFFE1;border-bottom:1px solid #666666;';
pNode.innerHTML = "Javascript检测到你的分辨率为" + screen.width + 'x' + screen.height + ',' + '字号自动设置为' + font_size;
}
changeFontSize();
window.onresize=function()
{
changeFontSize();
}
</script>