Reputation: 29
I have an Iframe something like this.
<iframe id="test" src="test.html">
</iframe>
In my test.html
I want to add a script to change width and height of iframe.
<script>
$(document).ready(function() {
$('#test').attr("width", "510px");
});
</script>
But its not working.
Upvotes: 0
Views: 66
Reputation: 7794
You need to do something like this inside
the iframe html page.
Width:
<script>
window.parent.document.getElementById("test").width = 900;
</script>
Height:
<script>
window.parent.document.getElementById("test").height = 900;
</script>
Upvotes: 1
Reputation: 9759
Inside the IFrame you can resize the IFrame with this snippet:
<script>
parent.document.getElementById('test').style.width = "510px";
</script>
Just be careful, when you get into IFrames you'll run into browser security sandboxing, which could cause troubles interacting with content inside the iframe from outside of it or vice versa.
Upvotes: 0