比如说,有一个top.html文件,当分辨率为800×600时,显示<table name="table1">...</table>的HTML内容,当分辨率为1024×768时,显示<table name="table2">...</table>的HTML内容,这样应该怎样使用JavaScript语句来实现这个功能,而且需要在一个HTML文件中实现。请各位前辈高手多多指教,小弟不胜感激!
解决方案 »
- JQuery div选择器问题 急急急急急急
- Toolbar 中的store 可以动态设置么?
- offsetTop,scrollHeight,scrollTop理解不是很清楚
- PS如何做水印交错平铺效果啊?
- js 高手进
- 关于解决ie6 fixed问题
- jquery动态添加html元素
- javascript 里面的Scripting.FileSystemObject 能不能访问客户端文件系统
- 急急!!版本help!!请问如果用javascript或者php语言实现当打开查个面页时就要求安装或者运行某个程序,有没有相关的程序(在线等)
- 几个简单问题请教
- 关于数据更新语句
- javaScript局部打印预览
比如:width="100%" 自适应大小
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>例子</title>
<script type="text/javascript">
//function klass(){
// this.a.apply(this,arguments);
//}
//klass.prototype.a = function(){};
//var test = new klass("a","b");
//alert(test.a);
window.onload = function(){
if(window.screen.width == "800" && window.screen.height == "600")
{
document.getElementById("a").style.display = "block";
document.getElementById("b").style.display = "none";
}
else if (window.screen.width == "1024" && window.screen.height == "768")
{
document.getElementById("a").style.display = "none";
document.getElementById("b").style.display = "block";
}
}
</script>
</head>
<body>
<table id="a"><tr><td>aaaaaaaaaa</td></tr></table>
<table id="b"><tr><td>bbbbbbbbbb</td></tr></table>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> 例子 </title>
<script type="text/javascript">
window.onload = function(){
if(window.screen.width == "800" && window.screen.height == "600")
{
document.getElementById("a").style.display = "block";
document.getElementById("b").style.display = "none";
}
else if (window.screen.width == "1024" && window.screen.height == "768")
{
document.getElementById("a").style.display = "none";
document.getElementById("b").style.display = "block";
}
}
</script>
</head>
<body>
<table id="a"> <tr> <td> aaaaaaaaaa </td> </tr> </table>
<table id="b"> <tr> <td> bbbbbbbbbb </td> </tr> </table>
</body>
</html>
那楼主这样看看
<script language="javascript">if (document.readyState=="complete")
{
AdjustImageSize();
}
else
{
document.onreadystatechange = function()
{
if (document.readyState == "complete")
{
AdjustImageSize();
}
}
}
AdjustImageSize()就是根据分辨率判断的事件
<img src="简介MENU3.jpg" width="243" height="161" id="cc">
<script language="javascript">
if (document.readyState=="complete")
{
init();
}
else
{
document.onreadystatechange = function()
{
if (document.readyState == "complete")
{
init();
}
}
}
function init(){
o = document.getElementsByTagName("IMG")
for(i=0;i <o.length;i++)
if(o[i].width> 100 ) o[i].width=500
}</script>