没明白你的意思。我写的你看看能用就采用
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> </title>
</head>
<style>
.img{
position: fixed
z-index: 10
top:50%
left: 50%
margin-top: -200px
margin-left: -200px
}
#close{
position: absolute
left: 10px
top: 5px
}
body{
background-color: #333
}
</style>
<body>
<div class="mask"></div>
<div class="img">
<span id="close">关闭</span>
<img src="dd.png" alt="">
</div>
</body>
<script>
var mask = document.getElementById('close')
var img = document.getElementsByTagName('img')[0]
mask.onclick=function(){
img.style.display = "none"
this.style.display = "none"
}
</script>
</html>
没明白你的意思。我想的是打开页面的时候就是一个弹窗状态,当我点击关闭后弹窗图片消失。我中间的白色“找不到服务器”是图片
可以测试一下以下代码:
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var rotate_delay = 5000 // delay in milliseconds (5000 = 5 secs)
current = 0
function next() {
if (document.slideform.slide[current+1]) {
document.images.show.src = document.slideform.slide[current+1].value
document.slideform.slide.selectedIndex = ++current
}
else first()
}
function previous() {
if (current-1 >= 0) {
document.images.show.src = document.slideform.slide[current-1].value
document.slideform.slide.selectedIndex = --current
}
else last()
}
function first() {
current = 0
document.images.show.src = document.slideform.slide[0].value
document.slideform.slide.selectedIndex = 0
}
function last() {
current = document.slideform.slide.length-1
document.images.show.src = document.slideform.slide[current].value
document.slideform.slide.selectedIndex = current
}
function ap(text) {
document.slideform.slidebutton.value = (text == "Stop") ? "Start" : "Stop"
rotate()
}
function change() {
current = document.slideform.slide.selectedIndex
document.images.show.src = document.slideform.slide[current].value
}
function rotate() {
if (document.slideform.slidebutton.value == "Stop") {
current = (current == document.slideform.slide.length-1) ? 0 : current+1
document.images.show.src = document.slideform.slide[current].value
document.slideform.slide.selectedIndex = current
window.setTimeout("rotate()", rotate_delay)
}
}
// End -->
</script>
<center>
<form name=slideform>
<table cellspacing=1 cellpadding=4 bgcolor="#000000">
<tr>
<td align=center bgcolor="white">
<b>图片循环</b>
</td>
</tr>
<tr>
<td align=center bgcolor="white" width=200 height=150>
</td>
</tr>
<tr>
<td align=center bgcolor="#C0C0C0">
<select name="slide" onChange="change()">
<option value="图片地址" selected>图片
<option value="图片地址">图片
<option value="图片地址">图片
<option value="图片地址">图片
<option value="图片地址">图片
<option value="图片地址">图片
<option value="图片地址">图片
<option value="图片地址">图片
<option value="图片地址">图片
<option value="图片地址">图片
</select>
</td>
</tr>
<tr>
<td align=center bgcolor="#C0C0C0">
<input type=button onClick="first()" value="|<<" title="Beginning">
<input type=button onClick="previous()" value="<<" title="Previous">
<input type=button name="slidebutton" onClick="ap(this.value)" value="Start" title="AutoPlay">
<input type=button onClick="next()" value=">>" title="Next">
<input type=button onClick="last()" value=">>|" title="End">
</td>
</tr>
</table>
</form>
</center>
JavaScript 是属于网络的脚本语言! JavaScript 被数百万计的网页用来改进设计、验证表单、检测浏览器、创建cookies,以及更多的应用。
很明显, 你'OpenImg(images/h-imgs/bg.jpg)',这个方法的参数你没加引号,应该传入一个字串才对,你目前的写法,在js里会认为你传入的是个变量。你把组img标签的代码改成下面这样试试看:
"<img src='"+src+"' onclick='OpenImg(\""+src+"\")'/>"