SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    May 2011
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Jquery help advice

    Hi all

    My first post so apologies if I've done anything incorrectly.

    I'm after some jquery help and advice about where to place my js.

    At present I'm putting this site together for a client.

    Proofreading - We right what you write

    It curently has 3 slideshows on the homepage at the clients request. My first question is about where to place my code. At the moment I have....

    Code:
    <script type="text/javascript">
    $(document).ready(function() {
        $('.slideshow').cycle({
    		fx: 'scrollLeft',
    		speed:    600, 
            timeout:  5000,
    		pause: 1,
    		next:   '#next', 
            prev:   '#prev',
    		cleartypeNoBg: 'true'
    	});
    });
    </script>
    ...in my head tag. It works fine but I'm reusing this for my other two slide shows which are the logos down the bottom of the page.

    Is it correct to have this code 3 times, one after another in the head tag? or is there a better way to have this layed out?

    Also I'm just testing in IE8 and there seem to be a few issues..ones I've noticed are

    - The bottom logo slide shows dont move at the same time as they do in firefox. so in firefox they move as one like it's one long slideshow.

    - The top slideshow has a slight wobble in it and has now thrown in a mystery blank slide.

    I'm kind of stumped here and would appreciate any help.

    Thanks

  2. #2
    SitePoint Evangelist speda1's Avatar
    Join Date
    Jan 2002
    Posts
    550
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    To eliminate 3 code blocks, you could create a function to do the slideshow, passing in the element id if necessary, then call it from document.ready and onclick.

  3. #3
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,151
    Mentioned
    16 Post(s)
    Tagged
    3 Thread(s)
    They write for a living yet can't supply you with copy, now that is funny.

    Quote Originally Posted by villan007
    Is it correct to have this code 3 times, one after another in the head tag? or is there a better way to have this layed out?
    The modern method is to place javaScript at the end of the body. That way the page can load without JS dragging it down.
    The only code I hate more than my own is everyone else's.

  4. #4
    SitePoint Member
    Join Date
    May 2011
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks oddz, that seemed to clear up everything.

    Still have one issue in IE8. If you look at the top slide show it wobbles on the right when it moves.

    Anybody have any ideas why?

    Cheers


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •