怎樣讓超過(guò)iframe框架高度限定自動(dòng)隱藏呢?

2021-08-05    分類(lèi): 網(wǎng)站建設(shè)

小編近在排版時(shí)發(fā)現(xiàn)iframe框架中的表單超過(guò)其框架高度后不知道應(yīng)該怎么被自動(dòng)隱藏,相信也有其他朋友同樣遇到過(guò)這種問(wèn)題,那么我們就一起來(lái)探究下應(yīng)該怎樣實(shí)現(xiàn)這個(gè)問(wèn)題吧,以下是小編經(jīng)過(guò)千辛萬(wàn)苦(有點(diǎn)夸大了啊,嘻嘻)才找到的一個(gè)解決方法:


<script type="text/javascript">
$(document).ready(function()
{
// Set specific variable to represent all iframe tags.
var iFrames = document.getElementsByTagName_r('iframe');

// Resize heights.
function iResize()
{
// Iterate through all iframes in the page.
for (var i = 0, j = iFrames.length; i < j; i++)
{
// Set inline style to equal the body height of the iframed content.
iFrames[i].style.height = iFrames[i].contentWindow.document.body.offsetHeight + 'px';
}
}

// Check if browser is Safari or Opera.
if ($.browser.safari || $.browser.opera)
{
// Start timer when loaded.
$('iframe').load(function()
{
setTimeout(iResize, 0);
}
);

// Safari and Opera need a kick-start.
for (var i = 0, j = iFrames.length; i < j; i++)
{
var iSource = iFrames[i].src;
iFrames[i].src = '';
iFrames[i].src = iSource;
}
}
else
{
// For other good browsers.
$('iframe').load(function()
{
// Set inline style to equal the body height of the iframed content.
if(this.contentWindow.document.body.offsetHeight>1000)
{
this.style.height = 700 + 'px';//此處為小高度的設(shè)置
}else{
this.style.height = this.contentWindow.document.body.offsetHeight + 'px';
}
}
);
}
}
);

</script>
看的懂么?哈哈,其實(shí)也不用看懂,只要把上述文件外加一個(gè)jquery文件一起加載下,你會(huì)發(fā)現(xiàn)你想要的效果已經(jīng)出現(xiàn)了...
以上信息來(lái)自創(chuàng)新互聯(lián),創(chuàng)新互聯(lián)科技有限公司專(zhuān)注于 營(yíng)銷(xiāo)型網(wǎng)站建設(shè) 、SEO整合推廣、企業(yè)形象網(wǎng)站建設(shè)、行業(yè)網(wǎng)站建設(shè)、綜合商城建設(shè)、,品牌解決方案。

網(wǎng)站欄目:怎樣讓超過(guò)iframe框架高度限定自動(dòng)隱藏呢?
本文路徑:http://www.muchs.cn/news2/120852.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站制作、面包屑導(dǎo)航搜索引擎優(yōu)化、營(yíng)銷(xiāo)型網(wǎng)站建設(shè)、網(wǎng)站建設(shè)動(dòng)態(tài)網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀(guān)點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話(huà):028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

網(wǎng)站托管運(yùn)營(yíng)