各位。
<iframe id="mainFrame" width="100%" height="100%" onload='IFrameReSize("mainFrame");IFrameReSizeWidth("mainFrame");' frameborder="0" scrolling="no" src="http://widget.weibo.com/list/list.php?language=zh_cn&width=1000&height=600&listid=441096097&uname=%E6%97%A0%E9%99%90%E9%9E%8D%E5%B1%B1&uid=2862199342&listname=%E9%9E%8D%E5%B1%B1%E7%94%B5%E8%A7%86%E5%8F%B0&color=&showcreate=0&isborder=1&showtitle=0&appkey=&dpc=1"></iframe>
width=1000&height=600
其中有个 宽和高。能不能用js 把这两个数用一个变量代替。因为不同的屏幕宽度不一样啊。
写成这样 width=daowidth&height=daoheight<script language=javascript>
var daowidth;
var daoheight;
function IFrameReSize(iframename) {
var pTar = document.getElementById(iframename);
if (pTar) { //ff
if (pTar.contentDocument && pTar.contentDocument.body.offsetHeight) {
pTar.height = pTar.contentDocument.body.offsetHeight;
daoheight=pTar.contentDocument.body.offsetHeight;
} //ie
else if (pTar.Document && pTar.Document.body.scrollHeight) {
pTar.height = pTar.Document.body.scrollHeight;
daoheight=pTar.Document.body.scrollHeight;
}
}
}
//iframe宽度自适应
function IFrameReSizeWidth(iframename) {
var pTar = document.getElementById(iframename);
if (pTar) { //ff
if (pTar.contentDocument && pTar.contentDocument.body.offsetWidth) {
pTar.width = pTar.contentDocument.body.offsetWidth;
daowidth=pTar.contentDocument.body.offsetWidth;
} //ie
else if (pTar.Document && pTar.Document.body.scrollWidth) {
pTar.width = pTar.Document.body.scrollWidth;
daowidth=pTar.Document.body.scrollWidth;
}
}
}
</script>
<iframe id="mainFrame" width="100%" height="100%" onload='IFrameReSize("mainFrame");IFrameReSizeWidth("mainFrame");' frameborder="0" scrolling="no" src="http://widget.weibo.com/list/list.php?language=zh_cn&width=1000&height=600&listid=441096097&uname=%E6%97%A0%E9%99%90%E9%9E%8D%E5%B1%B1&uid=2862199342&listname=%E9%9E%8D%E5%B1%B1%E7%94%B5%E8%A7%86%E5%8F%B0&color=&showcreate=0&isborder=1&showtitle=0&appkey=&dpc=1"></iframe>
width=1000&height=600
其中有个 宽和高。能不能用js 把这两个数用一个变量代替。因为不同的屏幕宽度不一样啊。
写成这样 width=daowidth&height=daoheight<script language=javascript>
var daowidth;
var daoheight;
function IFrameReSize(iframename) {
var pTar = document.getElementById(iframename);
if (pTar) { //ff
if (pTar.contentDocument && pTar.contentDocument.body.offsetHeight) {
pTar.height = pTar.contentDocument.body.offsetHeight;
daoheight=pTar.contentDocument.body.offsetHeight;
} //ie
else if (pTar.Document && pTar.Document.body.scrollHeight) {
pTar.height = pTar.Document.body.scrollHeight;
daoheight=pTar.Document.body.scrollHeight;
}
}
}
//iframe宽度自适应
function IFrameReSizeWidth(iframename) {
var pTar = document.getElementById(iframename);
if (pTar) { //ff
if (pTar.contentDocument && pTar.contentDocument.body.offsetWidth) {
pTar.width = pTar.contentDocument.body.offsetWidth;
daowidth=pTar.contentDocument.body.offsetWidth;
} //ie
else if (pTar.Document && pTar.Document.body.scrollWidth) {
pTar.width = pTar.Document.body.scrollWidth;
daowidth=pTar.Document.body.scrollWidth;
}
}
}
</script>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货