How to realize the adaptive height of IFRAME

Source: Internet
Author: User
Keywords Implementation height

Intermediary transaction http://www.aliyun.com/zixun/aggregation/6858.html ">seo diagnose Taobao guest cloud host technology Hall

several times to see someone ask questions about how to achieve the adaptive height of the IFRAME, able to automatically adapt to the length of the page to avoid the page and IFRAME at the same time the phenomenon of the scroll bar, just I also encountered a similar problem in the work, so the Internet search, East copy copy West Look, out of such a function , posted to the page can be used. Do not dare to enjoy, if you feel useful, welcome to use

The source code is as follows <code>

<script type= "Text/javascript" >

* * IFRAME automatically adapt to the page **//

Enter a list of the names of the IFRAME that you want to automatically adjust height based on the height of the page

Separate the IDs of each iframe with commas. For example: ["myframe1", "myframe2"], you can have only one form, no commas.

Define the ID of the IFRAME

var iframeids=["Test"]

If the user's browser does not support IFrame to hide the iframe and yes to hide, no means no hidden

var iframehide= "Yes"

function Dyniframesize ()

{

var dyniframe=new Array ()

For (i=0 i<iframeids.length; i++)

{

if (document.getElementById)

{

Automatically adjust the iframe height

Dyniframe[dyniframe.length] = document.getElementById (Iframeids[i]);

if (Dyniframe[i] &&!window.opera)

{

dyniframe[i].style.display= "Block"

if (dyniframe[i].contentdocument &&dyniframe[i].contentdocument.body.offsetheight)//If the user's browser is Netscape

Dyniframe[i].height = Dyniframe[i].contentdocument.body.offsetheight;

else if (dyniframe[i). Document &&dyniframe[i]. Document.body.scrollHeight)//If the user's browser is IE

Dyniframe[i].height = Dyniframe[i]. Document.body.scrollHeight;

}

}

To handle the display of browsers that do not support IFRAME based on set parameters

if ((document.all | | document.getelementbyid) &&iframehide== "no")

{

var tempobj=document.all? Document.all[iframeids[i]]: document.getElementById (Iframeids[i])

tempobj.style.display= "Block"

}

}

}

if (Window.addeventlistener)

Window.addeventlistener ("Load", Dyniframesize, False)

else if (window.attachevent)

Window.attachevent ("onload", dyniframesize)

Else

Window.onload=dyniframesize

</script>

</code>

When you use it, just stick it in the <head></head>.

How does an IFRAME embed a Web page? Author: Free Yong? Click: MT-8000? Last updated 2003-10-12

IFrame is not very common and is rarely used in standard Web pages. But a friend often asked, the following I briefly introduce its usage, you just master these parameters enough.

<iframe> should also be a form of a framework, unlike <frame>, where an IFRAME can be embedded in any part of a Web page. We give the first example, the specific code such as:

<iframe width=420 height=330 frameborder=0 scrolling=auto src=url></iframe> the URL here can be a relative path or an absolute path, and the effect will be:

width, height means width, can be adjusted according to the actual situation.

Scrolling indicates whether the page scroll bar is displayed, the optional parameter is auto, yes, and no, and if this argument is omitted, auto is the default.

Second, how to implement the hyperlinks on the page to the embedded Web page?

Just name the IFRAME. The method is <iframe Name=**>, for example I named AA, to write this HTML language <iframe width=420 height=330 name=aa frameborder=0 Www.liuyebo.com></iframe>, and then, the hyperlink statement on the page should be written as: <a Href=url target=aa>

If the frameborder is set to 1, the effect is like a text box.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.