jquery tab select and then bookmark scrollTo content -


code working with

$(".jumpto3").click(function() {         $("ul.tabs li").removeclass("active"); //remove "active" class          $("ul.tabs li.start").addclass("active"); //add "active" class selected tab         $(".tab_content").hide(); //hide tab content         var activetab = $("#tab1"); //find rel attribute value identify active tab + content         $(activetab).fadein(); //fade in active content          return false;     }); 

i have working scrollto function working on page too. problem is, can link tab page fine, can't select tab , scrollto, in order.

javascript:bookmarkscroll.scrollto('requirements') 

i thinking "return false" messing ?

here link tab, works fine:

http://www.website.com/advertise/#tab1 

this 1 doesn't:

http://www.website.com/advertise/#tab1?scrollto=requirements 

i'm sure missing pretty simple in js code ?

and here scrollto code:

//** scrolling html bookmarks script- (c) dynamic drive dhtml code library: http://www.dynamicdrive.com. //** available/ usage terms @ http://www.dynamicdrive.com/ (april 11th, 09') //** updated nov 10th, 09'- fixed anchor jumping issue in ie7  var bookmarkscroll={     setting: {duration:1000, yoffset:0}, //{duration_of_scroll_milliseconds, offset_from_target_element_to_rest}     topkeyword: '#top', //keyword used in anchors , scrollto() cause script scroll page top      scrollto:function(dest, options, hash){         var $=jquery, options=options || {}         var $dest=(typeof dest=="string" && dest.length>0)? (dest==this.topkeyword? 0 : $('#'+dest)) : (dest)? $(dest) : [] //get element based on id, topkeyword, or dom ref         if ($dest===0 || $dest.length==1 && (!options.autorun || options.autorun && math.abs($dest.offset().top+(options.yoffset||this.setting.yoffset)-$(window).scrolltop())>5)){             this.$body.animate({scrolltop: ($dest===0)? 0 : $dest.offset().top+(options.yoffset||this.setting.yoffset)}, (options.duration||this.setting.duration), function(){                 if ($dest!==0 && hash)                     location.hash=hash             })         }     },      urlparamselect:function(){         var param=window.location.search.match(/scrollto=[\w\-_,]+/i) //search scrollto=divid         return (param)? param[0].split('=')[1] : null     },      init:function(){         jquery(document).ready(function($){             var mainobj=bookmarkscroll             mainobj.$body=(window.opera)? (document.compatmode=="css1compat"? $('html') : $('body')) : $('html,body')             var urlselectid=mainobj.urlparamselect() //get div of page.htm?scrollto=divid             if (urlselectid) //if id defined                 settimeout(function(){mainobj.scrollto(document.getelementbyid(urlselectid) || $('a[name='+urlselectid+']:eq(0)').get(0), {autorun:true})}, 100)             $('a[href^="#"]').each(function(){ //loop through links "#" prefix                 var hashvalue=this.getattribute('href').match(/#\w+$/i) //filter links @ least 1 character following "#" prefix                 hashvalue=(hashvalue)? hashvalue[0].substring(1) : null //strip "#" hashvalue                 if (this.hash.length>1){ //if hash value more "#"                     var $bookmark=$('a[name='+this.hash.substr(1)+']:eq(0)')                     if ($bookmark.length==1 || this.hash==mainobj.topkeyword){ //if html anchor given id exists or href==topkeyword                         if ($bookmark.length==1 && !document.all) //non ie, or ie7+                             $bookmark.html('.').css({position:'absolute', fontsize:1, visibility:'hidden'})                         $(this).click(function(e){                             mainobj.scrollto((this.hash==mainobj.topkeyword)? mainobj.topkeyword : $bookmark.get(0), {}, this.hash)                             e.preventdefault()                         })                     }                 }             })         })     } }  bookmarkscroll.init() 

i'm not make sure version using

indeed, jquery.scrollto has offspring :)

jquery.localscroll: add scroll effect, anchor navigation. ideal slides, table of contents, etc. it's small, , incredibly easy implement.

jquery.serialscroll: it's multi-purpose plugin animate kind of sequential navigation(prev/next). it's small , highly customizable.

just @ library jquery.localscroll-1.2.7.js, can see take #param filter selector target scroll jump.

var uri = location.href.replace(/#.*/,''); // local url without hash 

and

function filter(){// link points anchor , passes possible filter ? href checked avoid bug in ff.             return !!this.href && !!this.hash && this.href.replace(this.hash,'') == uri && (!settings.filter || $(this).is( settings.filter ));         }; 

it makes sense since added more things attribute href , make messed this

http://www.website.com/advertise/#tab1?scrollto=requirements 

instead of using href, can assign param other attribute of anchor, example: custom="requirements", can stuff before scroll begin

$.localscroll({         target: '#content', // selector or jquery object too.         queue:true,         duration:1000,         hash:true,         onbefore:function( e, anchor, $target ){             console.log(e);             console.log(anchor);             console.log($target);             // 'this' settings object, can modified         },         onafter:function( anchor, settings ){             // 'this' contains scrolled element (#content)         }     }); 

http://jsfiddle.net/bkzlr/4/


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -