试图通过Ajax调用Ubergallery。我遇到了很多问题,我用下面的脚本解决了这些问题。现在一切都按我的意愿运行,除了一件事我没有导航按钮。你能帮我解决这个问题吗?
你可以在页面上看到我用ajax调用的按钮http://iliaspapantoniou.com/2/gallery.php但当你叫它的时候http://iliaspapantoniou.com/2/index.htm菜单音乐按钮不在那里。
提前感谢
$(document).ready(function(){
$(document).on("click", "a[rel='colorbox']", function(e){
e.preventDefault();
var url = this.href;
$.colorbox({href: url, maxWidth: "99%", maxHeight: "99%", opacity: ".5"});
});
});
我试图解决这个问题,但我意识到e.preventDefault();不要允许阅读库中的所有图像,并且单击的图像似乎是库中唯一的图像我想这就是我没有导航按钮的原因。有人能帮我查一下密码吗。如果我在没有e.preventDefault();剂量不能正常工作。非常感谢。
在index.htm上,我使用此ajax代码调用gallery.php
<script>
function gallery(){
var xmlhttp;
// code for IE7+, Firefox, Chrome, Opera, Safari
if (window.XMLHttpRequest){
xmlhttp=new XMLHttpRequest();
}
// code for IE6, IE5
else{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById("myDiv").innerHTML = xmlhttp.responseText;
}
}
xmlhttp.open("GET", "gallery.php", true);
xmlhttp.send();
}
</script>
gallery.php使用以下代码创建这些东西
<html>
<head>
<link rel="shortcut icon" href="Gallery/resources/themes/uber-naked/images/favicon.png" />
<link rel="stylesheet" type="text/css" href="Gallery/resources/themes/uber-naked/rebase-min.css" />
<link rel="stylesheet" type="text/css" href="Gallery/resources/UberGallery.css" />
<link rel="stylesheet" type="text/css" href="Gallery/resources/colorbox/5/colorbox.css" />
<link rel="stylesheet" type="text/css" href="Gallery/resources/themes/uber-naked/style.css">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" ></script>
<script type="text/javascript" src="Gallery/resources/colorbox/jquery.colorbox.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("a[rel='colorbox']").colorbox({maxWidth: "90%", maxHeight: "90%", opacity: ".5"});
});
</script>
</head>
<body>
<?php include_once('Gallery/resources/UberGallery.php'); $gallery = UberGallery::init()->createGallery('Gallery/gallery-images'); ?>
</body>
</html>
当我打开gallery.php时,当我用ajax脚本调用它时,evrything是可以的,我没有导航按钮。你需要在index.htm上包含第一个脚本才能使用库有人能告诉我为什么会发生吗
在index.html中没有元素<a>
和rel='colorbox'
。
最终我找到了一个解决方案,我用iframe 调用gallery.php
<iframe id="iframeResult" frameborder="0" src="gallery.php" scrolling="no" height="100%" width="100%"></iframe>
我用AJAX 调用iframe(music.html)的页面
<script>
function Music()
{
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","files/Music.html",true);
xmlhttp.send();
}
</script>
唯一的问题是照片的增长与iframe 一样大