2
我有Modernizr加載問題。我正在使用Modernizr,jQuery和Nivo-slider。 有時當我刷新我的主頁時,我的滑塊顯示不正確,有時候一切都很好。Modernizr加載方法
我的方法是正確的嗎?
HTML:
<!-- SCRIPTS -->
<script type="text/javascript" src="js/plugins/modernizr-2.0.6.js"></script>
<script type="text/javascript" src="js/master.js"></script>
在master.js:
Modernizr.load([
{
load: 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js',
complete: function() {
if (!window.jQuery) {
Modernizr.load('js/plugins/jquery-1.7.1.js');
}
init();
}
},
{
load: 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js',
complete: function() {
if (!window.jQuery) {
Modernizr.load('js/plugins/jquery-ui-1.8.16.js');
}
}
}
]);
// START ******
function init() {
$(document).ready(function(){
// Home > Slider ----------------------------------------------
if($('#slider').length){
Modernizr.load([
{
both: [ 'js/plugins/jquery-nivoslider.js', 'css/nivo-slider.css' ],
complete: function(){
$('#slider').nivoSlider({
effect: 'fade', // Specify sets like: 'fold,fade,sliceDown'
animSpeed: 1000, // Slide transition speed
pauseTime: 5000, // How long each slide will show
startSlide: 0, // Set starting Slide (0 index)
directionNav: true, // Next & Prev navigation
directionNavHide: false, // Only show on hover
controlNav: true, // 1,2,3... navigation
controlNavThumbs: false, // Use thumbnails for Control Nav
controlNavThumbsFromRel: false, // Use image rel for thumbs
controlNavThumbsSearch: '.jpg', // Replace this with...
controlNavThumbsReplace: '_thumb.jpg', // ...this in thumb Image src
keyboardNav: true, // Use left & right arrows
pauseOnHover: true, // Stop animation while hovering
manualAdvance: false, // Force manual transitions
captionOpacity: 1, // Universal caption opacity
prevText: '', // Prev directionNav text
nextText: '', // Next directionNav text
randomStart: false, // Start on a random slide
beforeChange: function(){}, // Triggers before a slide transition
afterChange: function(){}, // Triggers after a slide transition
slideshowEnd: function(){}, // Triggers after all slides have been shown
lastSlide: function(){}, // Triggers when last slide is shown
afterLoad: function(){} // Triggers when slider has loaded
});
}
}
]);
}
});
}
// END ******
謝謝史蒂夫!你告訴我方式。它很適合很少的工作。 – Didav 2012-02-16 16:57:00
Modernizr.load([{ \t \t兩者: \t \t \t 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js', \t \t \t「 https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js' \t \t], \t \t完整:函數(){ \t \t \t如果(窗口! .jQuery){ \t \t \t \t Mo dernizr.load([{ \t \t \t \t \t兩者: \t \t \t \t \t \t 'JS /插件/ jQuery的1.7.1.js', \t \t \t \t \t \t「JS /插件/ jquery- UI-16年8月1日。JS' \t \t \t \t \t], \t \t \t \t \t完成:函數(){ \t \t \t \t \t \t的init(); \t \t \t \t \t} \t \t \t \t}]); \t \t \t}否則{ \t \t \t \t的init(); \t \t \t} \t \t} \t}]); – Didav 2012-02-16 16:59:27
@PaparazzoKid有任何機會花費你的時間來理解答覆和評論的代碼,而不僅僅是無用的評論。最好的祝福。 – Didav 2014-07-17 08:09:34