问题
How fix this problem in fancybox?
Uncaught TypeError: Object #<Object> has no method 'fancybox' localhost/:74
(anonymous function) http://localhost/:74
o.extend.ready.o.readyList jquery.min.js:19
o.extend.each jquery.min.js:12
o.extend.ready jquery.min.js:19
o.each.o.fn.(anonymous function)
Here is code in header.php I dont know where can be problem! I try use simplemodal but is not working! Maybe is problem with tabslider! I make everything that is write on fancybox website.
<link rel="stylesheet" href="css/jquery.fancybox-1.3.4.css" type="text/css" media="screen" />
<script type="text/javascript" src="js/jquery.fancybox-1.3.4.pack.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
$('.slide-out-div').tabSlideOut({
tabHandle: '.handle',
pathToTabImage: 'img/handle-bg.png',
imageHeight: '186px',
imageWidth: '30px',
tabLocation: 'left',
speed: 300,
action: 'click',
topPos: '150px',
leftPos: '20px',
fixedPosition: false
});
});
</script>
<script type="text/javascript">
$(function(){
$('.add_site_right').tabSlideOut({
tabHandle: '.handle_right',
pathToTabImage: 'img/handle-bg.png',
imageHeight: '186px',
imageWidth: '30px',
tabLocation: 'right',
speed: 300,
action: 'click',
topPos: '150px',
leftPos: '20px',
fixedPosition: false
});
});
</script>
<script type="text/javascript">
$(document).ready(function() {
/*
* Examples - images
*/
$("a#example1").fancybox();
$("a#example2").fancybox({
'overlayShow' : false,
'transitionIn' : 'elastic',
'transitionOut' : 'elastic'
});
$("a#example3").fancybox({
'transitionIn' : 'none',
'transitionOut' : 'none'
});
$("a#example4").fancybox({
'opacity' : true,
'overlayShow' : false,
'transitionIn' : 'elastic',
'transitionOut' : 'none'
});
$("a#example5").fancybox();
$("a#example6").fancybox({
'titlePosition' : 'outside',
'overlayColor' : '#000',
'overlayOpacity' : 0.9
});
$("a#example7").fancybox({
'titlePosition' : 'inside'
});
$("a#example8").fancybox({
'titlePosition' : 'over'
});
$("a[rel=example_group]").fancybox({
'transitionIn' : 'none',
'transitionOut' : 'none',
'titlePosition' : 'over',
'titleFormat' : function(title, currentArray, currentIndex, currentOpts) {
return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' ' + title : '') + '</span>';
}
});
/*
* Examples - various
*/
$("#various1").fancybox({
'titlePosition' : 'inside',
'transitionIn' : 'none',
'transitionOut' : 'none'
});
$("#various2").fancybox();
$("#various3").fancybox({
'width' : '75%',
'height' : '75%',
'autoScale' : false,
'transitionIn' : 'none',
'transitionOut' : 'none',
'type' : 'iframe'
});
$("#various4").fancybox({
'padding' : 0,
'autoScale' : false,
'transitionIn' : 'none',
'transitionOut' : 'none'
});
});
</script>
回答1:
You need to include fancybox script after jquery:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.fancybox-1.3.4.pack.js"></script>
回答2:
Your site adzire.com
throws javascript errors so that is making some of your scripts (including fancybox) to fail. You need to tide up your code a bit:
First, you only need a single instance of jQuery (ideally the latest version), so far you have 3 (1.4, 1.6.2 and 1.7.2). I guess you should remove v1.4 and 1.6.2 (some plugins include a copy jQuery but it doesn't mean you need them all.) Also make sure that load jQuery before any other script or jQuery plugin.
Second, same as jQuery, you only need a single instance of any of your jQuery plugins. You are loading jQuery UI 1.8.21 twice ... remove one. I guess because you load each of them after a different version of jQuery, it creates these erros:
Timestamp: 22/06/2012 11:35:54 AM
Error: $(".cont .wrapper .block select.styled").select_skin is not a function
Source File: http://www.adzire.com/js/main.js
Line: 6
Timestamp: 22/06/2012 11:36:03 AM
Error: detailsBox is not defined
Source File: http://www.adzire.com/
Line: 115
A bit of clean up might fix your issues, including fancybox issue.
来源:https://stackoverflow.com/questions/11155370/fancybox-not-working