Solved

how to set the height of iframe to 100% of the content

Posted on 2011-09-11
7
332 Views
Last Modified: 2012-05-12
hi i am going to give the oportunity to developers to use my page as resource for the bible. so they will add this script on their page:

<script type="text/javascript">
    quartelcristao_idb = "29";
    quartelcristao_idl = "692";
    quartelcristao_width = "950px";
</script>
<script src="http://www.quartelcristao.com/js/biblia/style01.js"></script>

but i want the iframe height to be 100% of the content. but not always is happening, don't know why. i try this on the style01.js file:

function QuartelCristao_Biblia_Resize_iframe() {
    var height = window.innerWidth; //Firefox
    if (document.body.clientHeight) {
       height = document.body.clientHeight; //IE
    }
    document.getElementById("QuartelCristao_Biblia_iframe").style.height = parseInt(height - document.getElementById("QuartelCristao_Biblia_iframe").offsetTop - 8) + "px";
}

window.onresize = QuartelCristao_Biblia_Resize_iframe;
 
(
function () {
   var url = "http://www.quartelcristao.com/js/biblia/style01/Default.aspx?";
    var current_location = window.location.hostname;
    url += "?" + "idb=" + quartelcristao_idb + "&idl=" + quartelcristao_idl;
    document.write("<iframe id='QuartelCristao_Biblia_iframe' width='" + quartelcristao_width + "' height='100%' frameborder=0 onLoad='QuartelCristao_Biblia_Resize_iframe()' src='" + url + "'></iframe>");
})()

Open in new window

0
Comment
Question by:rafaelrgl
  • 3
  • 3
7 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 36520095
line 2, why innerWidth? var height = window.innerWidth; //Firefox

else check this : http://www.slackcoders.com/2008/03/10/iframe-dynamic-resizing-solved/
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 36521052
Firefox also understands document.body.clientWidth now
0
 
LVL 1

Author Comment

by:rafaelrgl
ID: 36524878
this was just an code that i get on the internet. so we don't need this one anymore innerwidth?

something is wrong with my code any guess? or any changes i should make?
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 1

Author Comment

by:rafaelrgl
ID: 36539614
pls, if you have time help me
0
 
LVL 82

Expert Comment

by:leakim971
ID: 36539636
line 2, why innerWidth? var height = window.innerWidth; //Firefox

else check this : http://www.slackcoders.com/2008/03/10/iframe-dynamic-resizing-solved/
0
 
LVL 1

Author Comment

by:rafaelrgl
ID: 36539745
Sorry leakim971,

but i already delete this line and still same problem. and i also already read and did everything what this link shows? i think there is something wrong with that code on that page. did u test it before u gave this link or you just read solved on the link and did think it's solved?

sorry. but the problem still going on.
0
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 36539870
don't delete it

var height = window.innerWidth; //Firefox

I see innerWidth and height, logically it should be var height = window.innerHeight;
no? It was just a thought

https://developer.mozilla.org/fr/DOM/window.innerHeight
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
This article discusses how to create an extensible mechanism for linked drop downs.
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
The viewer will learn how to dynamically set the form action using jQuery.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now