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 7596555
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T21:56:40+00:00 2026-05-30T21:56:40+00:00

I have a slider, which responds to hash tag changes to move to the

  • 0

I have a slider, which responds to hash tag changes to move to the next or previous slide.
It does this by triggering the click event I have bound on my controls.
When I change the hash tag everything works as expected in IE 9 and Firefox.

However in Safari, Chrome and Opera an issue pops up when the only when right control is triggered by the script. If the left control is triggered it works fine. Which has caused me to be confused about the issue as its not consistent on both sides.

The issue it cases is that the whole slide appears as it its moved by two places instead of one, or three instead of two. Basically as if its moved by an extra space each time.
The confusing thing is is that when I check the #slideInner it says that the margin left has moved by the right amount, but it still appears as if its moved an extra space.

Here is an example of the code I used.

HTML

<!DOCTYPE html>
<html lang="en">
<head></head>
<body>
<div id="rightarrow" class="control">&nbsp;</div>
<div id="wrap">
<div id="slideshow">
<div id="slidesContainer">
<div id="slideInner>
<div id="homes" class="slide"> stuff in here </div>
<div id="blogs" class="slide"> stuff in here </div>
<div id="portfolio" class="slide"> stuff in here </div>
</div>
</div>
</div>
</div>
<div id="leftarrow" class=" control">&nbsp;</div> 
</body>
</html>

CSS for the slider elements

#slideshow #slidesContainer
{
margin:0 auto;
width:936px; 
overflow: hidden;
position:block;
background-color: transparent;

}

#slideshow 
{   
width: 100%;
}

#slideInner
{
position: relative;
}

JS

$(document).ready(function(){

var = slideWidth = '936';
var = currentPosition = 0;
var slides = $('.slide');
var numberOfSlides = slides.length;

$('#slideInner').css('width', slideWidth * numberOfSlides);


$('.control').bind('click', function(){
// Determine new position
  currentPosition = ($(this).attr('id')=='rightarrow')
? currentPosition+1 : currentPosition-1;      

 function
  $('#slideInner').animate({'marginLeft' : slideWidth*(-currentPosition)}, 1500);
});

$(window).load(function() { 
 hashchange();  
});

function hashchange()   
{                               
$(window).hashchange(function(){    

  // If hashchange happens whilst in state One
    if (currentPosition == 0 && location.hash == '#blogs' )
             {
    // click right once to slide two        
            $('#rightarrow').trigger('click');     
        }
else
    if (currentPosition == 0 && location.hash == '#portfolio' )
    {
    // click right twice to page three
    $('#rightarrow').trigger('click');
    $('#rightarrow').trigger('click');
    }

// iif hashchange happens whilst in state two
else 
    if (currentPosition == 1 && location.hash == '#portfolio' )
    {
    //click right once to page three
    $('#rightarrow').trigger('click');  
    }
else                                
    if (currentPosition  == 1 && location.hash == '#homes' )
    {
    // click left once to page one
    $('#leftarrow').trigger('click');   
    }

    //..... and so on with more slides 
  });
  • 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-30T21:56:41+00:00Added an answer on May 30, 2026 at 9:56 pm

    Well, rather than deal with the issue you’re talking about, overall, I’d just rearrange the code so that you’re not triggering events that way. What you’re doing at the moment is really inefficient and will take you ages if you have to add more slides. Something like:

    // create array of all your pages
    var slides = ["#homes", "#blogs", "#portfolio"];
    $('.control').bind('click', function(){
        // Determine new position
        currentPosition = $(this).attr('id')=='rightarrow' ? currentPosition+1 : currentPosition-1;      
        moveToPage(currentPosition);
    });
    
    function moveToPage(){
        $('#slideInner').animate({'marginLeft' : slideWidth*(-currentPosition)}, 1500);
    }
    
    $(window).hashchange(function(){    
        currentPosition = $.inArray(location.hash, slides);
        moveToPage();
    });
    

    Might be more efficient.

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

Sidebar

Related Questions

I have a slider which is made by jQuery. It uses next and previous
I have a slider which contains 6 videos per slide, so I have a
I am making a portfolio website and have a horizontal slider which will slide
I have this code which auto plays my slider, how ever at the the
I have three texboxes and one slider which changes their Text properties. What i
I have used coin slider which is extracted from this site http://workshop.rs/projects/coin-slider/ . It
I have this jQuery plugin called Easy Slider which I'm implementing on this site
I have this slider which displays in a lightbox/modal. There are 2 buttons that
I have to make a horizontal month slider which will have two pointers which
I'm working on http://lobounce.com.s138810.gridserver.com/ and have been having some problems with the slider which

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.