Reputation: 127
i want to change the height of an iframe with Jquery (the iframe is runat=server). And height does not change.
What's wrong with my code??
iframe tag:
<iframe style="height: 956px; width: 100%" frameborder="0" runat="server" id="ift"></iframe>
And JQuery:
$(document).ready(function () { $(window).resize(function () { $('#ift').height($(window).height()) }); });
Upvotes: 0
Views: 184
Reputation: 2028
You should add ClientIDMode="Static"
to your iframe.
Alternatively you can add a class to your iframe and target the class instead of the id like so
$('.YourIframeCSSclass').height($(window).height());
Also you forgot to put a semicolon after resizing the Iframe.
Upvotes: 0
Reputation: 11340
If it's runat=server
you can't guarantee the id since ASP.NET changes it. Try:
<iframe style="height: 956px; width: 100%" frameborder="0" runat="server" id="ift" ClientIDMode="Static"></iframe>
Upvotes: 1