This is exactly what I've been looking for as just using the following with
Interface 1.2 makes # links to other pages completely unusable:
$(document).ready(
function()
{
$(document).ScrollToAnchors(630);
}
);
But I'm afriad to say that none of this works for me :( I've been using the
whole of interface.js 1.2, not just the ScrollTo plugin, but that shouldn't
make a difference should it?
Brandon Aaron wrote:
>
> 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
>
--
View this message in context:
http://www.nabble.com/Smooth-Scrolling-for-same-page-links-tf3245806.html#a9053361
Sent from the JQuery mailing list archive at Nabble.com.
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/