如果我在一个iframe中加入一个图片 ifrmae.document.execCommand("InsertImage","","url");然后我如何再能取得该图片对象呢?
---------------------------------------------------------------
1<iframe id="web"></iframe>
1<script>
2function window.onload(){
3web.document.designMode='on';web.document.open();web.document.clear();web.document.write(" ");
4}
5function document.onclick(){
6temp1=web.document.images.length
7web.focus();web.document.execCommand("InsertImage","abc","url") //这个是弹出对话框的
8if(temp1<web.document.images.length){ //如果插入之后比插入之前,多了一个图片对象则。。。
9alert(web.document.images[web.document.images.length-1].outerHTML)
10}
11}
12</script>
下面还有一个例子
1<iframe id="web"></iframe>
1<script>
2function window.onload(){
3web.document.designMode='on';web.document.open();web.document.clear();web.document.write(" ");
4}
5function document.onclick(){
6web.focus();web.document.execCommand("InsertImage","","url") //这个是不弹出对话框的
7alert(web.document.images[web.document.images.length-1].outerHTML) //不需要检索,直接得到最后一个图片对象
8}
9}
10</script>
---------------------------------------------------------------
var a=iframe.getElementsByTagName("img")
for(var i=0,i<a.length;i++){
alert(a[i].src) //遍历iframe中的所有图片
}