循环显示照片

<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
</head>
<body>
美图
<%
	String json = "{images:[{'id':'1', 'title':'美女', 'url':'/js/images/a.jpg'}, {'id':'2', 'title':'女儿', 'url':'/js/images/b.jpg'}]}";
%>
<img id="pp" src="/js/images/a.jpg" />
<script type="text/javascript">
	var oImages = <%=json%>;
	var i = 0;
	alert(oImages.images.length);
	function player(){
		document.getElementById('pp').src = oImages.images[i++ % oImages.images.length].url;
	}		

	setInterval(player, 3000);
</script>
</body>
</html>

你可能感兴趣的:(java,html,json)