I've been working on integrating Colorbox (a lightbox alternative) into a site.
Ok, so my head file is:
<head>
<script language="javascript" type="text/javascript" src="js/jquery.js"></script>
<link type="text/css" media="screen" rel="stylesheet" href="../colorbox/colorbox.css" />
<script type="text/javascript" src="../colorbox/jquery.colorbox.js"></script>
<script type="text/javascript">
function saveToBook() {
$.fn.colorbox({inline:fa开发者_如何学JAVAlse, href:'../index.html'});
};
</script>
</head>
My Link is as follows:
<a href="#save-to-book" onclick="javascript:parent.saveToBook();return false;" class="recipe-links">Save to Cookbook</a>
The only output I recieve (from FireBug) is:
$.fn.colorbox is not a function
My best guess would be that ../colorbox/jquery.colorbox.js
is not the correct path, are you sure it's not something like this?
<script type="text/javascript" src="js/colorbox/jquery.colorbox.js"></script>
Also, your script should be more like this:
$(function() {
$("a[href='#save-to-book']").click(function() {
$(this).parent().colorbox({inline:false, href:'../index.html'});
return false;
});
});
And just remove your current function and the onclick
from the anchor itself.
Hey, sorry for wasting peoples time - I had been running this on my local machine.
I just decided to upload it to a beta server and it all functions fine, obviously didn't like my path names :)
Thanks @NickCraver for giving it a shot, and cheers @PetersenDidlt
Hey see below this is your code where you close script 2
<script language="javascript" type="text/javascript" src="js/jquery.js"></script></script>
精彩评论