iFrame Auto Resize

I have an iFrame that I'm trying to auto size like this:

<script  type="text/javascript">
    function setHeight() {
        parent.document.getElementById('test').height = document['body'].offsetHeight;
    }

</script>
<iframe src="http://murfreesboro.granicus.com/ViewPublisher.php?view_id=2" frameborder=0 id="test" onload="setHeight()" scrolling=auto class=media    ></iframe>

(from the css) :
.media
{
    width:100%;
   min-height:350px;
   
}

The page that the iframe is displaying comes from another location.  I do not have access to its code.  When the page loads, the javascript appears to work, but the page does not size to 100% of its contents.  The page inside of the iframe refreshes itself periodically, and when it does, the javascript incrementally adds extra height to the page. I would like to stop that incremental resizing if possible.   The page that I'm working on can be found here: http://64.1.44.148/stage/cablearchive.aspx?ekmenu=106 

I want the iframe to resize its height based on its contents. Is there a way to do that? Please let me know if I need to explain my problem any further.  Thanks for reading.
thedeal56Asked:
Who is Participating?
 
glumlunConnect With a Mentor Commented:
hi, in VB a page scrape function would look like this:

    Public Function scrapeContent() As String

        Dim objWebClient As New WebClient()
        Dim strURL As String = "http://www.domain.com/page.htm"
        Dim aRequestedHTML() As Byte

        aRequestedHTML = objWebClient.DownloadData(strURL)
        Dim objUTF8 As New Text.UTF8Encoding()

        Return objUTF8.GetString(aRequestedHTML)

    End Function

by calling this you would get the whole content of a page in a string.

id recomend saving the string to a html file on your local server, and using it as the source of yout iframe

i have noticed that there are a lot of references in the iframe source to external files, these would need to be replaced with absolute urls using the replace function

without being able to access the code on the external domain you have no choice but to use scrollbars, try to predict the size of the page, or use scraping.

thanks
glum
0
 
glumlunCommented:
Hi. Unfortunately you cannot resize your iframe based on the height of the document loading into it if it's from a different domain to the document requesting it.  This is a security issue.
A good alternative is to do a page scrape  
If u need info on this please let me know.
0
 
thedeal56Author Commented:
Yes, some more info on that would be helpful.  Thanks for your fast reply.
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

 
thedeal56Author Commented:
That's cool.  I'll look into that.  Thanks agian.
0
 
thedeal56Author Commented:
I forgot to ask this:

This site is using the same company's external link, but they are displaying it through a traditional frame set.  If I were to use regular frames, could I achieve the same result?

http://www.townofsmyrna.org/

From the site, click on departments -> channel 3 -> archives

That should put you to it.
0
 
glumlunCommented:
hi, as the src of the iframes is on the same domain your original scripts should work no problem.
ill monitor this post in case you have further questions

thanks
glum
0
 
thedeal56Author Commented:
I'm not sure how to go about writing it to a html file.  Would it be too much trouble to ask for some help with that?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.