<jsp:useBean id="db" class="Bean.DBBean" scope="page" /><%String a="select * from video";ResultSet rs=db.executeQuery(a);int num=0;ArrayList<String> arraylist=new ArrayList<String>();while (rs.next()){arraylist.add(rs.getString(3));num++;}rs.first();%><script language=javascript>var divId=1;//動(dòng)態(tài)生成單純的divfunction CreateOuterDiv(){<%int number=0;%>for (loop=0;loop<"<%=num%>";loop++){var obj=document.createElement("div");obj.id="myDiv"+divId;divId++;obj.style.border="1px solid #000000";obj.style.height="200px";obj.style.width="100%";obj.style.filter="alpha(opacity=70)";obj.style.margin="10px";obj.style.cursor="hand";obj.algin="center";//obj.addEventListener('click',ClickTest);//document.getElementById(obj.id).onclick=ClickTest();//obj.setAttribute("onclick","ClickTest()")(function () {var url='<%=arraylist.get(++number)%>';//加單引號(hào)!obj.onclick=function () {top.location='danmu.jsp'+'?'+url;}})();//obj.onclick=ClickTest(url);document.body.appendChild(obj);}}function ClickTest(url) {return function(){top.location='danmu.jsp'+'?'+url;}}</script>
為什么我找的函數(shù)閉包不管用 ?
米脂
2023-03-12 17:13:17