0

This might be a little confusing to explain, but I've been up all night pondering it and I can't seem to get in right.

I have an Iframe running on my website, inside the iframe is one image with one link. This is what is inside of the iframe from what I grabbed out of FireBug.

<head>
<body style="background-color:transparent; margin:0; outline-offset:0;">
<div style="text-align:center;">
<a onclick="document.location.reload(true);" href="http://randomwebsite.com/THE-URL-I-NEED" target="_blank">
<img width="160" height="600" border="0" src="http://randomwebsite.com/RANDOM-IMAGE.JPG">
</a>
</div>
</body>
</html>

Now, I need to grab that single URL and set it as a variable using Jquery, then set the variable as a link outside the iframe. So I was thinking something like this.

<a id="myiframelink" href=""></a>
<script>$("#myiframelink").attr("href","URL-FROM-INSIDE-IFRAME");</script>
Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
Dustin
  • 6,207
  • 19
  • 61
  • 93

1 Answers1

2

if the embedded iframe url is not same as your domain, there is no way to grab that url. Otherwise, you can use something like

$($('iframe')[0].contentWindow.document.body).search("a").attr('href')
Nakul
  • 1,574
  • 11
  • 13
  • It's not possible at all even if the frame has fully loaded? Like this? $("#myiframelink").attr($('#iframeid')[0].contentWindow.document.body).search("a").attr('href') – Dustin Nov 10 '11 at 10:28