问题
I am totally baffled. I have reduced this to the simplest possible case and run it through W3c's validator and I still get this tiny Fancybox window. I've used Fancybox many many times. Looks like this:
Page is here: http://www.ericaspindler.com/private/
Code has had all other JS and CSS stripped out in an effort to locate interference.
The entire document:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Erica Spindler | Author</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script src="http://code.jquery.com/jquery-latest.js" type="text/javascript"></script>
<script type="text/javascript" src="../js/fancybox_new/jquery.fancybox-1.3.1.js"></script>
<link rel="stylesheet" type="text/css" href="../js/fancybox_new/jquery.fancybox-1.3.1.css" media="screen" />
<script type="text/javascript">
$(document).ready(function(){
$("#infolink").fancybox({});
$("#infolink").click();
});
</script>
</head>
<body>
<div id="fancy" style="display:none;">
<div style="width:500px; height:500px">
<img src="../g/video_Faulkner_Society_300.jpg" width="300" height="243" alt="" />
</div></div>
<a id="infolink" href="#fancy" class="infolink" style="display:none"></a>
</body>
</html>
The original HTML content of the #fancy div was reduced to this one image in an effort to clarify.
Also removed the parameters I was initializing with:
$(".infolink").fancybox({
'scrolling' : 'no',
'titleShow' : false,
'overlayOpacity' : '0.7'
});
Can anyone tell me my error?
回答1:
The display: none
should be set on the parent div of the one you want to act as a box. See #4 (inline content) in the documentation.
So move the id="fancy"
to the child div like this:
<div style="display:none;">
<div style="width:500px; height:500px" id="fancy">
HERE is the example.
回答2:
I don't know if this will help but your jQuery isn't written well what.
$(document).ready(function(){
$("#infolink").fancybox();
});
let me know if this helps at all, if not I'll keep looking into it.
来源:https://stackoverflow.com/questions/8508773/jquery-fancybox-showing-up-tiny