Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7641869
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:02:22+00:00 2026-05-31T09:02:22+00:00

can someone please help with the window.location.hash and the .cycle script. I’ve been trying

  • 0

can someone please help with the window.location.hash and the .cycle script. I’ve been trying for weeks now and i can not do it, i’m learning javascript part time and i’m no where near capable of completing this without some help.

Here’s the html code i have

<div id="home_slide" class="slide">
  <li class="header"><a href="#" class="goToSlide" data-jim="#about_us_slide">About us</a></li>
  <li class="header"><a href="#" class="goToSlide" data-jim="#contact_us_slide">Contact us</a></li>
  <li id="back"><a href="#" class="prev_demo" data-jim="#home_slide">Home</a></li>
</div>

<div id="about_us_slide" class="slide">
  <li class="header"><a href="#" class="goToSlide" data-jim="#about_us_slide">About us</a></li>
  <li class="header"><a href="#" class="goToSlide" data-jim="#contact_us_slide">Contact us</a></li>
  <li id="back"><a href="#" class="gohome" data-jim="#home_slide">Home</a></li>
</div>

<div id="contact_us_slide" class="slide">
  <li class="header"><a href="#" class="goToSlide" data-jim="#about_us_slide">About us</a></li>
  <li class="header"><a href="#" class="goToSlide" data-jim="#contact_us_slide">Contact us</a></li>
  <li id="back"><a href="#" class="gohome" data-jim="#home_slide">Home</a></li>
</div>

​

Heres the CSS code i have

<style type='text/css'>
#container {
width: 320px;
height: 417px;

}
#nav li {
float: left;
}
#nav li a {
display: block;
border: 1px solid #333;
background: #eee;
}
#slide_containers {
clear: both;
border: 1px solid #333;
background: #eee;
}
.slide {
width: 100%;
}
#about_us_slide {
background: #cea;
width: 320px;
height: 417px;
}
#contact_us_slide {
background: #fea;
width: 320px;
height: 417px;
}

</style>

and finally here is the javascript code i have
//

$('.goToSlide').click(function(e) { 
// Bind click event to all elements with the class goToSlide
e.preventDefault();
var selector = $(this).data('jim'); // Get the data-slide attribute value
//console.log(selector, $(selector), $(selector).index()); // DEBUG
var slideIndex = $(selector).index(); // Get the index of the slide element
$('#slide_containers').cycle(slideIndex); // Cycle to slide by index
});});
//]]>  
</script>

Here’s also a jsfiddle of the code working
http://jsfiddle.net/mYmrx/16/

What i’m trying to do is have my domain name i.e. http://www.domain.com#about_us or even better would be http://www.domain.com/about_us

Please can someone help me, i am going crazy.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T09:02:24+00:00Added an answer on May 31, 2026 at 9:02 am

    You are quite close. You can set window.location.hash to your ‘selector’ variable to get pretty much what you are asking for. You can even do it after the animation completes using promise and done. Here is an example:

    $(function() {
        $('#slide_containers').cycle({
            fx: 'scrollLeft',
            speed: 'fast',
            timeout: 0,
            prev: ".prev_demo",
        });
    
        // Bind click event to all elements with the class goToSlide
        $('.goToSlide').click(function(e) {
            e.preventDefault();
            // Get the data-slide attribute value
            var selector = $(this).data('jim');
            // Get the index of the slide element
            var slideIndex = $(selector).index();
            $('#slide_containers').cycle(slideIndex);
            // wait for animation to complete
            var promise = $('.slide').promise();
            promise.done(function() {
                // set hash
                window.location.hash = selector;
            });
        });
    
        //Grab hash off URL (default to first tab) and update
        $(window).bind("hashchange", function(e) {
            var anchor = $(location.hash);
            if (anchor.length === 0) {
                $('#slide_containers').cycle(0);
            }
            var slideIndex = $(anchor).index();
            $('#slide_containers').cycle(slideIndex);
        });
    });​
    

    ​Here is the updated JSFiddle: http://jsfiddle.net/infiniteloops/AHATV/8/

    Here you can see the JSFiddle in action (with the updated hash locations): http://jsfiddle.net/infiniteloops/AHATV/8/show/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wonder whether someone can help please. I'm trying to put together a script
Can someone help me out please...I'm trying to start my first programming project. It
Can someone please help me figure out why my accordion script at http://www.mincovlaw.com/services/copyright gets
Can someone please help me out with printing the contents of an IFrame via
Can someone please help me? In Perl, what is the difference between: exec command;
Can someone please help quickly mute or unmute the stage volume in Flash CS3
can someone please help me. why does this return an error: Dim stuff As
Can someone please help me with using Regex with NSPredicate? NSString *regex = @(?:[A-Za-z0-9]);
Can someone please help me out with a JavaScript/jQuery solution for this arithmetic problem:
Can someone please help me figure out a way to achieve the following (see

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.