tags:

views:

58

answers:

4

Hi,

I am using Iframe and In Iframe a dynamic image is loding. I want to use that Image as a link to the respective article. Actually this is a news site.

I already have used many stuffs like:

<a href="whatever.."><iframe src="dynamic url"></iframe></a>

does work with IE but not with safari and FF.

and

some tweets like

div.iframe-link {
    position: relative;
}
a.iframe-link1 {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
}

code:

<div class="iframe-link">
    <iframe src="file" width="90px" height="60px" frameborder="0" scrolling="no"
     marginheight="0" marginwidth="0" allowtransparency="true" noscaling="true">
    </iframe>
    <a href="url" target="_top" class="iframe-link1"></a>
</div>

worked in FF and Safari not in IE7,8.

SO can anybody suggest what to do..

any help would be appreciated.

+1  A: 

If the iframe is loading an HTML page, just put your <a> tags in the source of that.

If it is just loading an image, why are you not using an <img> tag?

DanSingerman
But i cant change that page... beacuse this is other site sending image.... I simply wanna make this image clickable...
Anil
If the other site is just providing an image, why not put use that in the img's src attribute?
ThatBlairGuy
the images are dynamic in size.so i only need to display upper left 90X60 size image. rest part automatically should cut off. thats the rest i used iframe not to distort the image.I need small part but clear part. Thanxx for reply
Anil
@user400210 - then you could use inline CSS: give your `<a>` a `display:block` property, `width:90px;height:60px;` and a `background-image` which refers to the other site.
LeguRi
See my updated answer for a similar method without using background-images.
Eric
Thanxx Guys ...It worked............. Thanks so so much.... By the way it took my lots of time...Once again thanks..
Anil
A: 

The Iframe is loading a dynamic address of image like::::

<div class="news_img01">
    <div onclick="window.open('URL','_self')" style="cursor: pointer;"><br>
        <iframe scrolling="no" height="60px" frameborder="0" width="90px" noscaling="true" allowtransparency="true" marginwidth="0" marginheight="0" src="thumbnails/1188.gif">
        </iframe>
    </div>
</div>

so i cant add tag inside but already wrapped tag inside . it worked for IE but not for others like FF, Safari..

Thanxx for reply

Anil
Please, merge this with the original question. It's not an answer, so it shouldn't have been given as one.
Eric
... doesn't this idea violate some sort of same-source/same-domain policy? I'm no expert on JS secutiry, so I'm not sure...
LeguRi
No, I don't think there's any violation. Besides, judging by the relative url for the image, it's all on the same domain anyway.
Eric
+2  A: 

According to your earlier comments, you were using the iframe in order to crop an image of unknown size to a 60 by 90 pixel box. Do do this, use the overflow:hidden css attribute on the a tag, which slices off any content not fitting within the border-box.

<div class="news_img01">
    <a href="URL"
       style="display: block; width:90px; height:60px; overflow:hidden;">
        <img src="thumbnails/1188.gif" />
    </a>
</div>
Eric
Thanxx Guys ...It worked............. Thanks so so much.... By the way it took my lots of time...Once again thanks..
Anil
If this answers your question, **then click the tick on the left**!
Eric
A: 

I would recommend using jQuery to select the image element in that iframe and wrap it with <a> tag so it's clickable.

I believe it's possible to attach an onHTMLReady listener to the document inside the iframe. Then wait for the iframe to load and then make the image clickable

$(frames[0].document).ready(function(){ /*find and wrap with a-tag goes here*/ });
Peter Perháč
I am newbie in Jquery. Can you please Elaborate.
Anil