On Jan 10, 2007, at 9:32 AM, Andy Matthews wrote:
More importantly you can do this with CSS instead of javascript:
True, but...
http://www.hunlock.com/blogs/Attach_icons_to_anything_with_CSS.
http://www.askthecssguy.com/2006/12/
showing_hyperlink_cues_with_cs_1.html
both of these solutions require use of the attribute selector, which
IE6 and below don't recognize.
If you want it to work in IE < 7, JavaScript/jQuery is the way to go.
Better yet, do both. That way modern browsers with JavaScript turned
off will still see the icons.
--Karl
_________________
Karl Swedberg
www.englishrules.com
www.learningjquery.com
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:discuss-
[EMAIL PROTECTED] On
Behalf Of Klaus Hartl
Sent: Tuesday, January 09, 2007 5:06 PM
To: jQuery Discussion.
Subject: Re: [jQuery] Play around with JQuery
Olaf Bosch schrieb:
Olaf Bosch schrieb:
Errors are, all Links are find. $("#text a").favicon(); is the
Selector.
Oh, i stupid, i close not the DIV, dammit :)
That's not the problem but inside the each loop "this" is a DOM
element and
not a jQuery object, thus this.append(cue) won't work.
It has to be: jQuery(this).append(cue)
Also, if you intend to make that plugin chainable
(jQuery.fn.favicon) you
have to use:
return this.each(...);
And maybe you don't need to use all the regular expressions to
parse the
domain. There are properties ready to use:
this.hostname would give you "www.google.com"
All in all, try this:
jQuery.fn.favicon = function () {
return this.each(function() {
var hoststring = /^http:/i;
var hrefvalue = this.getAttribute("href");
if (hrefvalue.search(hoststring) != -1) {
var domain = this.hostname;
var cuesrc = "http://"+domain+"/favicon.ico";
var cue = "<img class=\"favicon\" src=\""+cuesrc+"\" alt=
\"\" />";
jQuery(this).append(cue);
}
});
};
-- Klaus
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/