Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

I'm new in web programming and now i got a chance to use iframe in my asp.net web app project.I'd like to resize iframe which is second level frame according to its content size.How do i achieve it? Anyone wants to help me out? Thanks in advance.
Posted
Updated 6-Sep-14 10:24am
v3

Give CSS Style Using Code Behind or Using JavaScript or J-query.

Ex 1.

Quote:

$("#iframe").width($("#content").width()) ;
$("#iframe").height($("#content").height()) ;


Quote:

$("#iframe").attr("width",$("#content").attr("width"));
$("#iframe").attr("height",$("#content").attr("height"));


Ex 2.

Quote:


iframe.Width = content.Width
iframe.Height = content.Height

 
Share this answer
 
I alret content height and parent frame's height.They are the same value.But i can't see full content in parent frame.
 
Share this answer
 
JavaScript
function IFrameResize(obj)
  {
    var contentHeight;

    contentHeight=obj.contentWindow.document.body.scrollHeight;
    obj.style.height= contentHeight + 'px';
    window.parent.document.getElementById("parentframe").style.height = 
    contentHeight + 'px';
    
    alert(contentHeight);
    alert(window.parent.document.getElementById("parentframe").style.height);
  }


I call that above function in child frame onload event.
Parent frame need to be resized according to child frame content size.
How to achieve it?
Thanks in advance.

P.S
I can see my content when i press middle mouse click and all the way scroll down to bottom. So content is just hidden. Is it scrolling problem or something? 
I think it almost there already.
 
Share this answer
 
v4
Show me your code or give me the source code of project or anything. I will solve it.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900