iframe中插入图片

iframe中插入图片,第1张

<iframe src="filename.asp?参数" iframe其他参数></iframe>

filename.asp里面 <img src="<%=src%>" img其他参数>

使用iframe传递的参数,处理以后生成对应的图片源src

另外,可使用js

file.htm

<iframe id="f" src="filename.htm" iframe其他参数></iframe>

<script language=javascript>

var i=0

function s(){

var a=new Array('1.gif','2.gif','3.gif')

f.getElementsByTagName("img")[0].src=a[i%3]

return

}

</script>

<input onclick='s()' type=button value='click'>

filename.htm

<img src=1.gif img其他参数 />

第一种:

<script type="text/javascript">

function reinitIframe(){

var iframe = document.getElementById("mainFrame")//id改为你的iframe的id

try{

var bHeight = iframe.contentWindow.document.body.scrollHeight

var dHeight = iframe.contentWindow.document.documentElement.scrollHeight

var height = Math.max(bHeight, dHeight)

iframe.height = height

}catch (ex){}

}

window.setInterval("reinitIframe()", 200)

</script>

第二种

<script>

//IFrame自适应高度

function reinitIframe(){

var iframe = document.getElementById("infoshowiframeid")//IFRAME id

try{

var bHeight = iframe.contentWindow.document.body.scrollHeight

var dHeight = iframe.contentWindow.document.documentElement.scrollHeight

var height = Math.max(bHeight, dHeight)

iframe.height = Math.max(height,400)

// alert(height)

}catch (ex){}

}

window.setInterval("reinitIframe()", 200)

</script>


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/tougao/11370724.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-15
下一篇2023-05-15

发表评论

登录后才能评论

评论列表(0条)

    保存