Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2011-09-11
7
Medium Priority
?
362 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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 2000 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article discusses how to implement server side field validation and display customized error messages to the client.
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Suggested Courses

972 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