我在接受的答案here中找到了此代码... 它将iframe加载到特定区域 通过按钮点击...
<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);
}
如何更改此设置以便我可以设置高度宽度并滚动?
答案 0 :(得分:2)
theIframe.style.*
您要设置样式的任何属性。
答案 1 :(得分:2)
这不是jQuery,而是纯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);
}
这不是你问题的一部分,但这里是你用jQuery切换div的方法:
标记:
<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();
});
});