gpt4 book ai didi

javascript - Ubergallery 和 ajax

转载 作者:行者123 更新时间:2023-11-28 07:34:15 25 4
gpt4 key购买 nike

尝试通过 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 脚本调用它时,一切都正常,但我没有导航按钮。您需要在index.htm 上包含第一个脚本才能使用图库谁能告诉我为什么会发生这种事

最佳答案

index.html中没有元素<a>rel='colorbox' .

关于javascript - Ubergallery 和 ajax,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28780761/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com