javascript - When I click a link, click a link on another page? -
really struggling think of solution problem. have thought anchor links might (using #example on end of link scroll position on page) not sure how best implement them.
so on homepage of site have list of links, correlate tabs on page.
the links on homepage: (what e-bate, rebates etc.) links
when click 1 of tabs on other page, activates script shows div below: tabs
this how tabs shown:
html:
<div class="page-links"> <ul> <li><a href="#" onclick="return false;" class="whatebate">what e-bate?</a></li> <li><a href="#" onclick="return false;" class="whatrebate">what rebates?</a></li> <li><a href="#" onclick="return false;" class="ebatefeat">e-bate features</a></li> <li><a href="#" onclick="return false;" class="howebate">how e-bate works</a></li> <li><a href="#" onclick="return false;" class="casestud">case studies</a></li> </ul> </div> <div class="page-contents"> <div id="whatebate" class="hideshowdiv"> <?php echo cfs()->get('whatisebate'); ?> </div> <div id="whatrebate" class="hideshowdiv"> <?php echo cfs()->get('what_are_rebates'); ?> </div> <div id="ebatefeat" class="hideshowdiv"> <?php echo cfs()->get('e_bate_features'); ?> </div> <div id="howebate" class="hideshowdiv"> <?php echo cfs()->get('how_e_bate_works'); ?> </div> <div id="casestud" class="hideshowdiv"> <?php echo cfs()->get('case_studies'); ?> </div> </div>
jquery:
jquery(document).ready(function() { jquery(".page-contents div.hideshowdiv").hide(); // show chosen div, , hide others jquery("a").click(function (e) { //e.preventdefault(); jquery("#" + jquery(this).attr("class")).fadein().siblings('div.hideshowdiv').hide(); }); });
so when 1 of links clicked on homepage, instance, 'what e-bate?' link, want go other page, , click corresponding tab, showing content section. possible? in advance.
this possible , had half equation anchors. need write small function parse out url , check tag.
so this:
$(function(){ if (location.href.indexof("#example") != -1) { //this put function show tab } if (location.href.indexof("#anotherexample") != -1) { //this put function show tab } })
Comments
Post a Comment