当前位置:编程学习 > JS >>

JavaScript图片选择器

JavaScript图片选择器,用Select下拉框选择图片,然后跳转并显示出来。为了演示速度 ,这里调用的图片比较小,实际使用时你可以更换图片。
答案:<html>
<head>
<title>JavaScript图片选择器</title>
<script language="javascript">
<!--
	function selectImg(){
		imgURL = form1.select.value;
		img = new Image();
		if (imgURL !== ""){
			img.src = imgURL;
			str  = "<img src = " + imgURL + ">";
			str += "<center><input type='button' value='关闭'";
			str += "onclick='self.close()'></center>";
			while(img.width<0){}
			wh = "width=" + (img.width+20) +",height=" + (img.height+50);
			p = open("","",wh);
			p.document.write(str);
		}
	}
//-->
</script>
</head>
<body>
<form name="form1" method="post" action="">
  <select name="select" onChange="selectImg()">
    <option>请选择相片</option>
    <option value="/jscss/demoimg/wall_s1.jpg">相片一</option>
    <option value="/jscss/demoimg/wall_s2.jpg">相片二</option>
    <option value="/jscss/demoimg/wall_s3.jpg">相片三</option>
    <option value="/jscss/demoimg/wall_s4.jpg">相片四</option>
    <option value="/jscss/demoimg/wall_s5.jpg">相片五</option>
  </select>
</form>
</body>
</html>

上一个:具备切片滤镜效果的JavaScript图片切换
下一个:可隐藏文字,支持缩略图的jQuery图片切换

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,