我如何以不同的方式实现此Javascript?

时间:2015-05-10 04:01:01

标签: javascript jquery

我购买了这个Javascript应用程序,它引起了很多关于它之后的任何javascript功能的问题。

我不太了解javascript。有没有其他方法可以编写/运行此脚本,以便它不会影响页面上我的所有其他JS?我不太了解JS。

此代码之后的任何JS都给我这个错误:TypeError:$不是函数

脚本:

var hap_players = [];   

        jQuery(document).ready(function($) {



            /* SETTINGS */

            var rvp_settings = {

                /* mediaId: unique string for player identification (if multiple player instances were used, then strings need to be different!) */

                mediaId:'player1',

                /* useDeeplink: true, false */

                useDeeplink:false,

                /*activePlaylist: Active playlist to start with. If no deeplink is used, enter element 'id' attribute, or if deeplink is used enter (data-address) deeplink string like 'playlist1'.  */

                activePlaylist:'playlist2',

                /*activeItem: Active video to start with. Enter number, -1 = no video loaded, 0 = first video, 1 = second video etc */

                activeItem:0,

                /* GENERAL SETTINGS */

                /*defaultVolume: 0-1 */

                defaultVolume:0.5,

                /*autoPlay: true/false (defaults to false on mobile)*/

                autoPlay:false,

                /*randomPlay: true/false */

                randomPlay:false,

                /* loopingOn: on playlist end rewind to beginning (last item in playlist) */

                loopingOn: true,

                /*autoAdvanceToNextVideo: true/false (use this to loop video) */

                autoAdvanceToNextVideo:true,

                /*autoOpenDescription: true/false  */

                autoOpenDescription:false,

                usePlaylist:true,

                useControls:true,

                /*autoHideControls: auto hide player controls on mouse out: true/false. Defaults to false on mobile. */

                autoHideControls:false,

                /*controlsTimeout: time after which controls and playlist hides in fullscreen if screen is inactive, in miliseconds. */

                controlsTimeout:3000,

                /*playlistOrientation: vertical/horizontal  */

                playlistOrientation:'horizontal',

                /*scrollType: scroll/buttons  */

                scrollType:'buttons',



                /* YOUTUBE SETTINGS */

                ytAppId:'AISyBtJyKdfdqgmhMuR9uqhj14gm89r-y9IP6CnE',/* youtube api key: https://developers.google.com/youtube/registering_an_application */

                ytTheme:'dark',

                ytShowinfo:true,



                /*playlistList: dom element which holds list of playlists */

                playlistList:'#playlist_list',



                /* showControlsInAdvert: true/false (show controls while video advert plays)  */

                showControlsInAdvert:true,

                /* disableSeekbarInAdvert: true/false (disable seekbar while video advert plays)  */

                disableSeekbarInAdvert:true,

                /* showSkipButtonInAdvert: true/false (show skip button while video advert plays)  */

                showSkipButtonInAdvert:true,

                advertSkipBtnText:'SKIP AD >',

                advertSkipVideoText:'You can skip to video in',



                logoPath: 'http://www.interactivepixel.net/images/jqueryPreviews/helper/apvplp_logo.png',

                logoPosition: '',/* tl, tr, bl, br */

                logoXOffset: 5,

                logoYOffset: 5,

                logoUrl: 'http://www.google.com',

                logoTarget: '_blank',



                useShare: false,

                /*fsAppId: facebook application id (if you use facebook share, https://developers.facebook.com/apps) */

                fsAppId:''



            };



            hap_players[0] = $('#mainWrapper').aprvp(rvp_settings);



        }); 

2 个答案:

答案 0 :(得分:0)

您将脚本包含在哪个顺序中?看起来这个视频播放器依赖于jQuery,因此必须在播放器的任何js文件之前定义jQuery。

                 

    <script type="text/javascript" src="js/jquery-1.11.0.min.js"></script>
    <script type="text/javascript" src="js/jquery.address.js"></script><!-- deeplink -->
    <script type="text/javascript" src="js/jquery.mousewheel.min.js"></script><!-- scroll -->
    <script type="text/javascript" src="js/jquery.jscrollpane.min.js"></script><!-- scroll -->
    <script type="text/javascript" src="js/froogaloop.js"></script><!-- vimeo -->
    <script type="text/javascript" src="js/jquery.dotdotdot-1.5.1.js"></script><!-- description shortener -->
    <script type="text/javascript" src="js/jquery.aprvp.min.js"></script>
    <script type="text/javascript">

答案 1 :(得分:0)

我遇到了同样的问题 - 它是在未缩小版本的最开始时声明$=jQuery.noConflict();的aprvp脚本产生的。经过两天的故障排除后,我发现您可以使用$替换javascript中jQuery的所有后续实例(这对我来说太费时),或者我承担风险并将其删除来自aprvp脚本的行,并自己重新缩小。到目前为止,这似乎对任何事情都没有负面影响。

希望这有帮助!