我自己有一个activex控件,加载到浏览器中
当控件尺寸足够时,不需要滚动条
当浏览器窗口缩小时,需要自动显示出滚动条以便用户可以通过滚动条看到被遮盖的部分请各位大虾说说,用js该怎么写?<HTML>
<head>
<title>xxxxx</title>
</head>
<body topmargin=0 bottommargin=0 leftmargin=0 rightmargin=0 onload="document.body.scroll='yes'">
<center>
<OBJECT
classid="clsid:xxxxxxxxxxxxxxxxxxxxxx"
width=100%
height=100%
align=center
hspace=0
vspace=0>
</OBJECT>
</center>
</body></html>
当控件尺寸足够时,不需要滚动条
当浏览器窗口缩小时,需要自动显示出滚动条以便用户可以通过滚动条看到被遮盖的部分请各位大虾说说,用js该怎么写?<HTML>
<head>
<title>xxxxx</title>
</head>
<body topmargin=0 bottommargin=0 leftmargin=0 rightmargin=0 onload="document.body.scroll='yes'">
<center>
<OBJECT
classid="clsid:xxxxxxxxxxxxxxxxxxxxxx"
width=100%
height=100%
align=center
hspace=0
vspace=0>
</OBJECT>
</center>
</body></html>
classid="clsid:xxxxxxxxxxxxxxxxxxxxxx"
width="200px"
height="150px"
align=center
hspace=0
vspace=0>
</OBJECT>
<head>
<title>xxxxx</title>
</head>
<body topmargin=0 bottommargin=0 leftmargin=0 rightmargin=0>
<center>
<div id="ObiFrame" style="width:500px;height:400px;overflow:auto;">
<OBJECT
classid="clsid:xxxxxxxxxxxxxxxxxxxxxx"
width=100%
height=100%
align=center
hspace=0
vspace=0>
</OBJECT>
</div>
</center>
</body></html>
div的大小如果不是固定的话,可以通过JS来控制
overflow:auto<div style="overflow:auto;">
</div>
我试了过了,还是有点问题我这个控件会根据窗口大小自动调整,只是当窗口大小小于1024*768时才需要滚动条,其他时候控件会自动充满窗口<div id="ObiFrame" style="width:1024px;height:768px;overflow:auto;">
当尺寸小于1024*768时滚动条是有了
但是当尺寸大于1024*768时控件不会自动充满整个窗口,它一直保持这个大小不变了要怎么办???如果解决问题了,再开帖送分
function OnResize()
{
if (窗口尺寸大于1024*768)
{
改变div到适和大小;
}
else
{
改变div为1024*768;
}
}
伪代码
{
var container =document.getElementById("ObiFrame");
container.style.height=document.documentElement.clientHeight;
container.style.width= document.documentElement.clientWidth ;
}
window.attachEvent("load",load);
window.attachEvent("resize",load);
何谓"通过js设置div容器的高度"?<HTML>
<head>
<title>xxxx</title>
</head>
<script language="JavaScript">
<!--function load()
{
var container =document.getElementById("ObiFrame");
container.style.height=document.documentElement.clientHeight;
container.style.width= document.documentElement.clientWidth ;
}
window.attachEvent("load",load);
window.attachEvent("resize",load);//-->
</script><body topmargin=0 bottommargin=0 leftmargin=0 rightmargin=0>
<center>
<div id="ObiFrame" style="width:1024px;height:768px;overflow:auto;">
<OBJECT
classid="clsid:xxxxxxxxxxxxxxxx"
width=100%
height=100%
align=center
hspace=0
vspace=0>
</OBJECT>
</div>
</center>
</body></html>该怎么样写呢?
我就是属于对JS一窍不通的那种水平
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js" ></script><div id="obj" style="width:100%;height:100%;background-color:#d23;overflow:auto;"></div>
<script>
function myresize()
{
var h=document.body.clientHeight;
var w=document.body.clientWidth; if(h<768){
$("#obj").height("768");
} if(w<1024){
$("#obj").width("1024");
} $("#obj").html($("#obj").html()+"I")
}
$(function(){myresize()});
$(window).resize(function(){myresize()});//IE在鼠标resize时就会不停的发resize事件.如果你一次移动只想发一次.可以查一下jquery的wresize事件</script>
另外flex的中对它的swf控件如何处理的,你也可以借鉴一下
<head>
<title>xxxxxxxx</title>
</head>
<script language="JavaScript">
function load()
{
var container=document.getElementById("ObiFrame");
var h=document.body.clientHeight;
var w=document.body.clientWidth; if(w<1024)
{
w=1024;
} if(h<768)
{
h=768;
} container.style.width=w;
container.style.height=h;
}window.attachEvent("load",load);
window.attachEvent("resize",load);</script><body topmargin=0 bottommargin=0 leftmargin=0 rightmargin=0>
<center>
<div id="ObiFrame" style="overflow:auto;">
<OBJECT
classid="clsid:xxxxxxxxxxxxxxxxxxxxx"
width=100%
height=100%
align=center
hspace=0
vspace=0>
</OBJECT>
</div>
</center>
</body></html>
<HTML>
<head>
<title>xxxxxxxx</title>
<script language="JavaScript">
function load()
{
var container=document.getElementById("ObiFrame");
var h=document.body.clientHeight;
var w=document.body.clientWidth;if(w<1024)
{
w=1024;
}if(h<768)
{
h=768;
}container.style.width=w;
container.style.height=h;
}window.attachEvent("load",load);
window.attachEvent("resize",load);</script>
</head>
<body topmargin=0 bottommargin=0 leftmargin=0 rightmargin=0>
<div id="ObiFrame" style="overflow:auto;">
<OBJECT
classid="clsid:xxxxxxxxxxxxxxxxxxxxx"
width=100%
height=100%
align=center
hspace=0
vspace=0>
</OBJECT>
</div>
</body></html>
var h=document.body.clientHeight;
var w=document.body.clientWidth;if(w<1024)
{
w=1024;
}if(h<768)
{
h=768;
}container.style.width=w;
container.style.height=h;仔细看这个代码,好象不是很对吧控件的大小它本身会自动调整的,当它在1024*768的时候它就保持这个尺寸不变了
如果此时窗口继续缩小,就需要滚动条了
我看这个代码似乎是在设定控件大小???