SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Jan 2010
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Two Scripts clashing, Help!!

    Hello All,

    Thanks for your interest in helping me solve this issue. I don't have a solid amount of experience solving issues in Javascript as I am more of a UI and Web Designer. Can someone help me solve this issue: I use the prototype.js (v1.7) script and the small script below.. When both included in the page, they both don't play together nicely.

    Here's the second script that's clashing with prototype.js:

    <script type="text/javascript">
    function moveScroller() {
    var a = function() {
    var b = $(window).scrollTop();
    var d = $("#scroller-anchor").offset({scroll:false}).top;
    var c=$("#scroller");
    if (b>d) {
    c.css({position:"fixed",top:"0px"})
    } else {
    if (b<=d) {
    c.css({position:"relative",top:""})
    }
    }
    };
    $(window).scroll(a);a()
    }
    </script>

  2. #2
    Just Blow It bronze trophy
    DaveMaxwell's Avatar
    Join Date
    Nov 1999
    Location
    Mechanicsburg, PA
    Posts
    7,289
    Mentioned
    122 Post(s)
    Tagged
    1 Thread(s)
    So what exactly is the issue you're having with it? Is it somewhere live we can see it?
    Dave Maxwell - Manage Your Site Team Leader
    My favorite YouTube Video! | Star Wars, Dr Suess Style
    Learn how to be ready for The Forums' Move to Discourse

  3. #3
    SitePoint Member
    Join Date
    Jan 2010
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Since it's for the company I work for, it's local at this time but I can upload the prototype.js script if you'd like?

    also this is what the header looks like:


    <head>
    <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />

    <title>
    <?php if ( is_home()) { bloginfo('name'); ?> - <?php bloginfo('description'); } ?>
    <?php if ( is_search()) { bloginfo('name'); ?> - <?php _e('Search Results', 'nattywp'); } ?>
    <?php if ( is_author()) { bloginfo('name'); ?> - <?php _e('Author Archives', 'nattywp'); } ?>
    <?php if ( is_single()) { $custom_title = get_post_meta($post->ID, 'natty_title', true);
    if (strlen($custom_title)) {echo strip_tags(stripslashes($custom_title));}else { wp_title(''); ?> - <?php bloginfo('name'); }} ?>
    <?php if ( is_page()) { $custom_title = get_post_meta($post->ID, 'natty_title', true);
    if (strlen($custom_title)) {echo strip_tags(stripslashes($custom_title));}else { bloginfo('name'); ?> - <?php wp_title(''); }}?>
    <?php if ( is_category()) { bloginfo('name'); ?> - <?php _e('Archive','nattywp'); ?> - <?php single_cat_title(); } ?>
    <?php if ( is_month()) { bloginfo('name'); ?> - <?php _e('Archive','nattywp'); ?> - <?php the_time('F'); } ?>
    <?php if (function_exists('is_tag')) { if ( is_tag() ) { bloginfo('name'); ?> - <?php _e('Tag Archive','nattywp'); ?> - <?php single_tag_title("", true); } } ?>
    </title>

    <?php /* Include the jQuery framework */
    wp_enqueue_script("jquery"); if (is_singular() && get_option('thread_comments')) wp_enqueue_script( 'comment-reply' ); ?>

    <?php wp_head(); ?>


    <!-- Feed link -->
    <link rel="alternate" type="application/rss+xml" title="<?php bloginfo('name'); ?> RSS Feed" href="<?php bloginfo('rss2_url'); ?>" />
    <link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />


    <!-- jQuery utilities -->
    <script type="text/javascript">var themePath = '<?php echo get_template_directory_uri(); ?>/'; // for js functions </script>
    <script type='text/javascript' src='<?php echo get_template_directory_uri(); ?>/js/superfish.js?ver=2.9.2'></script>
    <?php if (t_get_option('t_cufon_replace') == 'yes') { ?>
    <script type="text/javascript" src="<?php echo get_template_directory_uri(); ?>/js/cufon.js"></script>
    <script type="text/javascript" src="<?php echo get_template_directory_uri(); ?>/js/font.js"></script>
    <script type="text/javascript">Cufon.replace('.post .news-case h2 a, .timeblock span, h3, h2, span.fad, #top_nav li a', {hover:true});
    Cufon.replace('h2.title, .client-reviews h2',{hover: true, fontWeight: 700});
    </script>
    <?php } ?>


    <!-- Style sheets -->
    <link rel="stylesheet" type="text/css" href="<?php bloginfo('stylesheet_url'); ?>" media="screen" />


    <link href='http://fonts.googleapis.com/css?family=Carme' rel='stylesheet' type='text/css'>

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>

    <link rel="stylesheet" href="<?php echo get_template_directory_uri(); ?>/css/lightbox.css" type="text/css" media="screen" />
    <script src="<?php echo get_template_directory_uri(); ?>/js/prototype.js" type="text/javascript"></script>
    <script src="<?php echo get_template_directory_uri(); ?>/js/scriptaculous.js?load=effects,builder" type="text/javascript"></script>
    <script src="<?php echo get_template_directory_uri(); ?>/js/lightbox.js" type="text/javascript"></script>

    <script type="text/javascript">
    function moveScroller() {
    var a = function() {
    var b = $(window).scrollTop();
    var d = $("#scroller-anchor").offset({scroll:false}).top;
    var c=$("#scroller");
    if (b>d) {
    c.css({position:"fixed",top:"0px"})
    } else {
    if (b<=d) {
    c.css({position:"relative",top:""})
    }
    }
    };
    $(window).scroll(a);a()
    }
    </script>
    </head>

  4. #4
    Just Blow It bronze trophy
    DaveMaxwell's Avatar
    Join Date
    Nov 1999
    Location
    Mechanicsburg, PA
    Posts
    7,289
    Mentioned
    122 Post(s)
    Tagged
    1 Thread(s)
    Wow - that's a lot of scripting there. jQuery AND prototype AND scriptaculous and a lightbox. Are you sure it's the prototype it's barking at?

    Just a bit of advice for your own sanity's sake - you might want to look at seeing what you can sort out from all those javascript frameworks. There's a lot of cross functionality which probably isn't needed, so if you can find one that has the functionality you want, you should probably consider simplifying.

    I know jQuery has plugins which at least covers the lightbox...
    Dave Maxwell - Manage Your Site Team Leader
    My favorite YouTube Video! | Star Wars, Dr Suess Style
    Learn how to be ready for The Forums' Move to Discourse

  5. #5
    SitePoint Member
    Join Date
    Jan 2010
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by DaveMaxwell View Post
    Wow - that's a lot of scripting there. jQuery AND prototype AND scriptaculous and a lightbox. Are you sure it's the prototype it's barking at?

    Just a bit of advice for your own sanity's sake - you might want to look at seeing what you can sort out from all those javascript frameworks. There's a lot of cross functionality which probably isn't needed, so if you can find one that has the functionality you want, you should probably consider simplifying.

    I know jQuery has plugins which at least covers the lightbox...
    Haha, thanks Dave... I will definitely look into minimizing the resources for the site.


Tags for this Thread

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
  •