如何在页面上使用两个javascripts?

时间:2013-09-12 16:01:18

标签: javascript

我有一个从网上下载的下拉javascript工具栏和我在Dreamweaver小部件浏览器上创建的灯箱。但在我插入灯箱后,菜单栏无效。

http://alpineglass.biz/hardware.html

 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
    <script type="text/javascript" src="jquery.easing.1.3.js"></script>
    <script type="text/javascript">
        $(function() {
            /**
            * for each menu element, on mouseenter, 
            * we enlarge the image, and show both sdt_active span and 
            * sdt_wrap span. If the element has a sub menu (sdt_box),
            * then we slide it - if the element is the last one in the menu
            * we slide it to the left, otherwise to the right
            */
            $('#sdt_menu > li').bind('mouseenter',function(){
                var $elem = $(this);
                $elem.find('img')
                     .stop(true)
                     .animate({
                        'width':'170px',
                        'height':'170px',
                        'left':'0px'
                     },400,'easeOutBack')
                     .andSelf()
                     .find('.sdt_wrap')
                     .stop(true)
                     .animate({'top':'140px'},500,'easeOutBack')
                     .andSelf()
                     .find('.sdt_active')
                     .stop(true)
                     .animate({'height':'170px'},300,function(){
                    var $sub_menu = $elem.find('.sdt_box');
                    if($sub_menu.length){
                        var left = '170px';
                        if($elem.parent().children().length == $elem.index()+1)
                            left = '-170px';
                        $sub_menu.show().animate({'left':left},200);
                    }   
                });
            }).bind('mouseleave',function(){
                var $elem = $(this);
                var $sub_menu = $elem.find('.sdt_box');
                if($sub_menu.length)
                    $sub_menu.hide().css('left','0px');

                $elem.find('.sdt_active')
                     .stop(true)
                     .animate({'height':'0px'},300)
                     .andSelf().find('img')
                     .stop(true)
                     .animate({
                        'width':'0px',
                        'height':'0px',
                        'left':'85px'},400)
                     .andSelf()
                     .find('.sdt_wrap')
                     .stop(true)
                     .animate({'top':'25px'},500);
            });
        });
    </script>       

和另一个

             <script type='text/javascript' src='scripts/jquery.js'></script>
             <script type="text/javascript">
// BeginOAWidget_Instance_2127022: #gallery

    $(function(){
        $('#gallery a').lightBox({ 
            imageLoading:           '/images/lightbox/lightbox-ico-loading.gif',        // (string) Path and the name of the loading icon
            imageBtnPrev:           '/images/lightbox/lightbox-btn-prev.gif',           // (string) Path and the name of the prev button image
            imageBtnNext:           '/images/lightbox/lightbox-btn-next.gif',           // (string) Path and the name of the next button image
            imageBtnClose:          '/images/lightbox/lightbox-btn-close.gif',      // (string) Path and the name of the close btn
            imageBlank:             '/images/lightbox/lightbox-blank.gif',          // (string) Path and the name of a blank image (one pixel)
            fixedNavigation:        false,      // (boolean) Boolean that informs if the navigation (next and prev button) will be fixed or not in the interface.
            containerResizeSpeed:   400,             // Specify the resize duration of container image. These number are miliseconds. 400 is default.
            overlayBgColor:         "#999999",      // (string) Background color to overlay; inform a hexadecimal value like: #RRGGBB. Where RR, GG, and BB are the hexadecimal values for the red, green, and blue values of the color.
            overlayOpacity:         .6,     // (integer) Opacity value to overlay; inform: 0.X. Where X are number from 0 to 9
            txtImage:               'Image',                //Default text of image
            txtOf:                  'of'
        });
    });

// EndOAWidget_Instance_2127022                          

1 个答案:

答案 0 :(得分:0)

你要包含2份jQuery。不要那样做;这可能是你的问题。


在第一个块中,您包含3个脚本,第一个是jQuery:

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

在你的第二个区块中,你再次包括jQuery:

// From local
<script type='text/javascript' src='scripts/jquery.js'></script>

您应该只包含一次图书馆,如果本地版本与您从Google中删除的图片类似,那么它们都已经过时了。