I believe there are some syntax errors in the version Klaus posted.
Here is a version that *should* work (untested).
$('[EMAIL PROTECTED]"#"]').bind('click', function() {
if (location.pathname != this.pathname && location.host != this.host)
return;
var target = $(this.hash);
target = target.size() && target || $('[EMAIL PROTECTED]"' +
this.hash.slice(1) +'"]');
if (target.size()) {
target.ScrollTo(400);
return false;
}
});
Also if you are using the latest jQuery you can save a line and
unnecessary binds by writing it like this:
$('[EMAIL PROTECTED]"#"]').bind('click', function() {
var target = $(this.hash);
target = target.size() && target || $('[EMAIL PROTECTED]"' +
this.hash.slice(1) + '"]')
if (target.size()) {
target.ScrollTo(400);
return false;
}
});
--
Brandon Aaron
On 2/19/07, Karl Swedberg <[EMAIL PROTECTED]> wrote:
>
>
> On Feb 19, 2007, at 10:46 AM, Klaus Hartl wrote:
>
> hcabbos schrieb:
> Hey Klaus. Do you think you could post the new code that includes everyone's
> final recommendations?
>
> I think that is already the code I posted, I took Sam's improvements
> into account already... Karl?
>
>
> -- Klaus
> Yep, that was it. :)
>
> Here it is once more for good measure:
>
>
> $('[EMAIL PROTECTED]"#"]').click(function() {
> if (location.pathname == this.pathname && location.host == this.host) {
> var target = $(this.hash);
> target = target.size() && target || $("[EMAIL PROTECTED]" +
> this.hash.slice(1) +']');
>
> if (target.size()) {
> target.ScrollTo(400);
> return false;
> }
> });
>
>
>
> --Karl
> _________________
> Karl Swedberg
> www.englishrules.com
> www.learningjquery.com
>
>
> _______________________________________________
> jQuery mailing list
> [email protected]
> http://jquery.com/discuss/
>
>
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/