Reputation: 55
I found this code in the accepted answer here... which loads an iframe into a specific area via a button click...
<a href="#" onclick="setIframe(this,'http://www.stackoverflow.co.uk')" >Set the Iframe up</a>
function setIframe(element,location){
var theIframe = document.createElement("iframe");
theIframe.src = location;
element.appendChild(theIframe);
}
how do I change this so that it allows me to style the height width and scrolling?
Upvotes: 3
Views: 4060
Reputation: 17370
This is not jQuery, but pure Javascript:
function setIframe(element,location){
var theIframe = document.createElement("iframe");
theIframe.src = location;
theIframe.setAttribute("weight", "500");
theIframe.setAttribute("width", "500");
theIframe.setAttribute("scrolling", "yes");
element.appendChild(theIframe);
}
This is not part of your question, but here is how you toggle a div with jQuery:
Markup:
<input type="button" value="Toggle Div" id="btnToggle"/>
<div id="randomContent">
This is random Content.
<br />
This is random Content.
<br />
This is random Content.
<br />
This is random Content.
<br />
This is random Content.
<br />
This is random Content.
<br />
</div>
jQuery:
$(document).ready(function () {
$("#btnToggle").bind("click", function () {
$("#randomContent").toggle();
});
});
Upvotes: 2