Reputation: 31
i want to get these value "xxxxx" from the element "src" from these div
i tried so many getelements but it didn't work.
can anybody help me in that
<div id="iframe_container" >
<iframe name="I1" marginwidth="1" marginheight="1" width="100%" height="100%" frameborder="0" scrolling="auto" align="center" src="xxxxx" class="floating_iframe">
Your browser does not support inline frames or is currently configured not to display inline frames.
</iframe>
</div>
Upvotes: 0
Views: 109
Reputation: 4337
You need to:
document.getElementById
, document.getElementsByName
or any of other ways - depends if you're using any frameworks and what markup you have)getAttribute("src")
on that elemnt.Example ( http://jsfiddle.net/K3pEw/12/ ):
var iFrame = document.getElementsByName('I1');
alert("The src attribute of your iframe is: " + iFrame[0].getAttribute('src'))
Upvotes: 0
Reputation: 2510
If you have access to jQuery, you can write:
var src = $('#iframe_container iframe').attr('src');
Upvotes: 0
Reputation: 707248
If what you're trying to do is to get the src
of the iframe, you can use this code:
var iframes = document.getElementById("iframe_container").getElementsByTagName("iframe");
var src = iframes[0].src;
Upvotes: 1