0

There is an iframe inside a Master page. I would like the scrollbar to appear only for the Main page and not the Iframe. The iframe's height should increase along with the content.

I tried this but, the iframe height remains constant with or without content. The scrollbar appears for the iframe when there is large content. If I say scrolling=no, then the overflowing content remains hidden.

HTML:

<div class="content">
 <div class="page">
   <iFrame id="iframe1" runat="server" class="iframe" scrolling="no"></iframe>
 </div>
</div>

CSS :

.content
{
padding:2% 2%;
position:absolute;
top:90px;
left:250px;
border:1px solid aqua;
width:76%;
}
.page
{
 min-width:100%;
}
.iframe
{
border-style:none;
min-width:100%;
min-height:100%;
}

Any non Javascript solutions ?

Using chrome..

http://jsfiddle.net/a8jR8/

Ruby
  • 949
  • 7
  • 31
  • 68
  • Cause Im learning stuff and JS is too hard – Ruby Feb 23 '14 at 07:48
  • 1
    @Ruby Ok, but here is the solution: http://stackoverflow.com/questions/9162933/make-iframe-height-dynamic-based-on-content-inside-jquery-javascript/9163087#9163087 – Aristos Feb 23 '14 at 07:50
  • Thank you. That was exactly what I wanted but it works only if I remove the runat property from iFrame, otherwise the JS function cant find this id. How can I overcome this. First I put `document.getElementById('<%=iframe1.ClientID%>')`. And then `document.getElementById('iframe1')`. I need to access this control at server side to assign the src attributes – Ruby Feb 23 '14 at 08:18
  • In ASP.NET, the system presumes that the ID to `runat` controls is not unique (don't ask me why it thinks so), so it "salts" the control by prepending something like `ctl100_` to it. So iframe in the resulting HTML in the browser will have `id="ctl100_iframe1". The solution is to put `ClientIDMode="True"` in the start tag too, so that it won't change the ID. See [MSDN docs](http://msdn.microsoft.com/en-us/library/system.web.ui.control.clientidmode%28v=vs.110%29.aspx). – Mr Lister Feb 23 '14 at 09:03
  • I tried the solution at http://stackoverflow.com/questions/13854573/iframe-error-when-runat-server. No Luck. Error - No overload for method takes 0 arguments. – Ruby Feb 23 '14 at 09:16

0 Answers0