火狐里一个页里有两个iframe,在一个iframe怎么获取另一个iframe的src值

火狐里一个页里有两个iframe,在一个iframe怎么获取另一个iframe的src值,第1张

先取得主页面的iframe,再取得另一个iframe。

具体方法如下:在2个iframe中定义各自的id,在此假设他们的id分别为“A”和“B”,如果要让A获取B的src,则可以用这个方式:parentBdocumentgetElementById("你要取的东西的id")value;

这样就可以相互取值了。

用正则吧,相对容易一些,比如:

Dim ss, re, rv, Matches

ss = "<embed src=""/manage/editor/attached/media/20130607/20130607151919941994flv"" type=""application/x-shockwave-flash"" width=""550"" height=""400"" autostart=""false"" loop=""true""/>"

Set re = New RegExp

reGlobal = True

reIgnoreCase = True

reMultiLine = True

rePattern = "\bsrc\s=\s([""'])([^""']+)\1"

Set Matches = reExecute(ss)

responsewrite Matches(0)SubMatches(1) & " \ "

rePattern = "\bwidth\s=\s([""'])([^""']+)\1"

Set Matches = reExecute(ss)

responsewrite Matches(0)SubMatches(1) & " \ "

rePattern = "\bheight\s=\s([""'])([^""']+)\1"

Set Matches = reExecute(ss)

responsewrite Matches(0)SubMatches(1)

var imgobj = documentgetElementById("imgid"); //imgid为img标记的id字符串

var srcstr = imgobjsrc;//得到img标签的src属性内的值

var altstr = imgobjalt; //得到img标签的alt属性内的值

alert(srcstr);//打印img标签的src属性内的值

alert(srcstr);//打印img标签的alt属性内的值

<head>

<title></title>

<script type="text/javascript">

var i = 0;

function call() {

i++;

if (i % 2 != 0) {

documentgetElementById("img1")src = "images/2jpg";

}

else {

documentgetElementById("img1")src = "images/1jpg";

}

}

</script>

</head>

<body>

<img id="img1"src="images/1jpg" height="200px" />

<input type="button" name="name" value="换" onclick="call()" />

</body>

</html>

解释:我这是实现的两张的轮换,有什么不懂的留言吧。

以上就是关于火狐里一个页里有两个iframe,在一个iframe怎么获取另一个iframe的src值全部的内容,包括:火狐里一个页里有两个iframe,在一个iframe怎么获取另一个iframe的src值、Asp 中 获取视频标签的src的值 width height 的值、如何同时提取Img标签里的的src和alt属性内的值等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

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

原文地址:https://54852.com/web/9464940.html

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

发表评论

登录后才能评论

评论列表(0条)

    保存