Hi Dan,

Dan Atkinson wrote:
> Anyway, what I really wanted to do, was do a search of the iframe content
> for a favicon.ico link, and use it (or the link) as the icon for the
> floating window so that it would look a little nicer. Sure, it's a vanity
> thing, but I wasn't sure if it could have been done or not.

You can't read the <link href=""> directly, because (as I suspected and was
tripped-up by when testing just now) browsers deny access to iframed content
from other domains for security.

There are two workarounds I can think of:

1. Get the iframe's src attribute, reduce it to just the protocol and domain
(e.g. http://www.google.com ), and append "/favicon.ico" - and hope that
file exists... Then you'll (with luck) have a URL to play with, either in an  
or as a background-image in CSS. You can possibly avoid broken images by
loading it with JavaScript and inserting it with the image's onload event,
but I'm not sure.

2. Trickier, "full fat" solution: Grab the markup from the iframe's src URL
via AJAX, work on that to find a <link> with rel="icon" (preferred, I think)
or rel="shortcut icon", then piece together a complete URL as above... Not
so great, as it requires the browser to download all the markup of the
iframed content again, but it's pretty much guaranteed to work.

If the icon's URL is relative (doesn't start with a protocol or a slash), it
ought to work by prepending a slash, and then doing the same as in 1.


Also, you can see that in the commenting I've been trying to fix the iframe
width issue which is CSS'd by percentage, instead of static values. Any help
there would be appreciated!

The width was easy enough to whip into shape (only tested in Firefox 1.5,
not a CSS guru; YMMV):

#iframe {
width:100%;
height:100%;
border: 0;
}

For the height (which also appeared percentage-defined):

#jStatus {
        border-top: 1.5px solid #AAA;
        position: static;
        width:100%;
}

Avoiding "position: absolute;" usually makes things less of a headache when
it's an option, because (barring floats) elements will then stack nicely. I
think some borders will need adjusting to make the above CSS look right, so
it's certainly not perfect, but hopefully it'll help. =)

Regards,
Paul Chaplin
-- 
View this message in context: 
http://www.nabble.com/Getting-the-favicon-of-an-iframe--tf2550916.html#a7124472
Sent from the JQuery mailing list archive at Nabble.com.


_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to