Javascript 从信息盒调用弹出图像库?

Javascript 从信息盒调用弹出图像库?,javascript,popup,image-gallery,Javascript,Popup,Image Gallery,在我的博客文件夹中,我有两个子文件夹:地图和图库。地图有一个带有餐厅图标的交互式城市地图,gallery为每个餐厅提供了一个图像子文件夹。每个餐厅的图像文件夹当前包含两个附加文件:“get_images.php”从文件夹内容创建图像数组,以及“index.html”从该数组生成图库。我可以从地图上的信息框中调用每个餐厅的弹出式图像库,使用: boxText.innerHTML="<a href='javascript:popUp("+'"../gallery/'+restaurant+'/

在我的博客文件夹中,我有两个子文件夹:地图和图库。地图有一个带有餐厅图标的交互式城市地图,gallery为每个餐厅提供了一个图像子文件夹。每个餐厅的图像文件夹当前包含两个附加文件:“get_images.php”从文件夹内容创建图像数组,以及“index.html”从该数组生成图库。我可以从地图上的信息框中调用每个餐厅的弹出式图像库,使用:

boxText.innerHTML="<a href='javascript:popUp("+'"../gallery/'+restaurant+'/index.html"'+")'>gallery</a><br/>"
boxText.innerHTML=“
其中'restaurant'变量来自mySql数据库,“popUp”是创建弹出窗口的函数

这很麻烦,我不想在每个餐厅文件夹中都有get_images.php和index.html文件。我可以将get_images.php放在任何地方,并从主脚本调用它,但我正在努力找到一种方法来调用位于弹出窗口index.html中的rotate_images()函数。下面是函数:

var curimg=0
function rotate_images(){
document.getElementById("gallery").setAttribute("src", ""+galleryarray[curimg])
curimg=(curimg<galleryarray.length-1)? curimg+1 : 0
}
var curimg=0
函数rotate_images(){
document.getElementById(“gallery”).setAttribute(“src”,“”+galleryarray[curimg])

curimg=(例如,curimg将函数
rotate_images
放入名为
map.js
的文件中。 然后将该文件包含在任何需要该函数的html页面中

例如:

index.html

<head>
<!-- include map.js here -->
<script src="path/to/map.js"></script>
</head>
<body>
(...)
<a href="#" onclick='javascript:rotate_images(" + '"' + '../gallery/pizzahut/files/' + galleryarray[curimg] + '"' + ");return false'>gallery</a><br/>
(...)
</body>

(...)

(...)
谢谢你,Stephan。我会做必要的更改并回复你。一个问题:旋转图像函数的这一部分是否需要在href行的某个位置有一个id标记才能工作?
document.getElementById(“gallery”).setAttribute(“src”、“./images/”+galleryarray[curimg])
@2nu2no不需要id OK,我使用了您建议的过程,结果如下:重试-被5分钟的编辑规则捕获。结果是.php文件正在创建图像数组,.js文件正在接收数组并将其传递给主.html文件(我已通过警告框选中)但是,当我单击href链接时,我收到一条错误消息-“TypeError:document.getElementById(“slideshow”)为空”。我只能认为主文件中缺少对“slideshow”的引用是造成问题的原因。有什么想法吗?检查html页面中是否有id为='slideshow'的元素
<head>
<!-- include map.js here -->
<script src="path/to/map.js"></script>
</head>
<body>
(...)
<a href="#" onclick='javascript:rotate_images(" + '"' + '../gallery/pizzahut/files/' + galleryarray[curimg] + '"' + ");return false'>gallery</a><br/>
(...)
</body>