我将一个页面加载到一个 div 中,但我无法调整该 div 的大小
这里是代码行:
我的CSS:
<style type="text/css">
#calendar {
width:350px;
float:left;
padding:10px;}
</style>
html:
.
.
<div id="calendar"></div>
.
.
JavaScript:
<script type="text/javascript">
function divload(){
document.getElementById("calendar").innerHTML = '<object type="text/html"
data="/ISMS/calendar/index.php"></object>'; }
</script>
加载了对象的 innerHTML 是否应该以另一种方式调整大小?
谢谢你的帮助
最佳答案
将对象加载到 calendar
元素后,您可以使用 JS 调整 div 的大小。
function divload(){
var calDiv = document.getElementById("calendar"),
height = "300px", // or whatever you want the new height to be
width = "800px"; // or whatever you want the new width to be
calDiv.innerHTML = '<object type="text/html" data="http://printartsportal.com/"></object>';
calDiv.style.height = height;
calDiv.style.width = width;
calDiv.children[0].style.height = height;
calDiv.children[0].style.width = width;
}
关于javascript - div 大小调整与从 javascript 生成的内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26220606/