关于点击按钮弹出iframe的问题? javascript iframe html 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <button id='btn' value='click' onclick="document.getElementById('div1').style.display='block'">打开</button><div style="display:none" id="div1"> <iframe src="http://www.baidu.com" name="123" width="10%" height="300" scrolling="auto" frameborder="0"> </div> 不行啊,点击打开不弹出啊,我的button是循环添加到表格里的,是不是因为这个问题,所以打不开? 不行啊,点击打开不弹出啊,我的button是循环添加到表格里的,是不是因为这个问题,所以打不开?你要怎么弹出?我给的那个是将隐藏的div显示循环创建的代码贴下 不行啊,点击打开不弹出啊,我的button是循环添加到表格里的,是不是因为这个问题,所以打不开?你要怎么弹出?我给的那个是将隐藏的div显示循环创建的代码贴下 for (var i = 0; i < items.length; i++) { mytr = $("<tr valign='center' ><td align='center' width:200px;height:30px;overflow:hidden;white-space:nowrap;text-overflow: ellipsis;>" + items[i].id + "</td></td><td width:350px;height:30px;white-space:nowrap;overflow:hidden; text-overflow:ellipsis;-webkit-text-overflow:ellipsis; onclick='clickme(\"" + items[i].nm + "\")'>" + items[i].nm + "</td><td width:20px;><button id='btn' value='click' onclick='document.getElementById('div1').style.display='block''>打开</button></td></tr>"); mytab.append(mytr); } 关键是它也没将隐藏的DIV显示出来,点击之后一点反应都没有 div 有ID 的document.getElementById('div1').style.display='block' div 有ID 的document.getElementById('div1').style.display='block'<div style="display:none" id="div1">我按您写的给加上了可是没有反映 <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html><head id="Head1" runat="server"> <title>无标题页</title> <script src="jquery-1.6.2.js"></script> <%--<script>--%> <script type="text/javascript"> var pageCurrent=1,pagecount=0,count=0,pages=10; var status="",id_Current=null,type="";var ad_Current=""; $(function(){ $.ajax({ type:"post", dataType:"json", error:function(err,errstr){ alert("访问失败。"); }, url:"svr.aspx" , success:function(data) { var count=data.count; var items=data.items; creatTable(items,count); } }); }); function creatTable(items,count){ if (pagecount == 0) { pagecount = Math.ceil(count / pages); } var mytab = $("<table cellspacing='1' cellpadding='0' style='width:700px; table-layout:fixed;overflow:hidden;white-space:nowrap; display: table;'></table>"); var mytr3 =$("<tr align='center'width:200px;height:30px; overflow:hidden;white-space:nowrap;><td align='center' style='width:200px;height:30px;overflow:hidden;white-space:nowrap;font-weight:bold;' >ID</td><td align='center' style='width:350px;height:30px;overflow:hidden;white-space:nowrap;font-weight:bold;'>名称</td><td></td></tr>") mytab.append(mytr3); for (var i = 0; i < items.length; i++) { mytr = $("<tr valign='center' ><td align='center' width:200px;height:30px;overflow:hidden;white-space:nowrap;text-overflow: ellipsis;>" + items[i].id + "</td></td><td width:350px;height:30px;white-space:nowrap;overflow:hidden; text-overflow:ellipsis;-webkit-text-overflow:ellipsis; onclick='clickme(\"" + items[i].nm + "\")'>" + items[i].nm + "</td><td width:20px;><button id='btn' value='click' onclick='document.getElementById('123').style.display='block''>打开</button></td></tr>"); mytab.append(mytr); } var mytab2 =$( "<table style='width:700px;'><tr><td><div id='_txtTotalCount'>共"+count+"条</div><div id='_pageTotal' >第"+pageCurrent+"页,共"+Math.ceil(pagecount)+"页</div></td></tr><tr valign='right' width:200px;height:30px><td id='td1' align='right'width:200px;height:30px> <img id='firstpage' src='../css/images/clear.gif' class='disable1' border='1' title='首页' alt='首页'> <img id='prevpage' class='disable2' border='1'src='../css/images/clear.gif' title='上一页' alt='上一页'> <img id='nextpage' class='enable3' border='1'src='../css/images/clear.gif' title='下一页' alt='下一页'> <img id='lastpage' class='enable4' border='1'src='../css/images/clear.gif' title='尾页' alt='尾页'></td></tr></table>");// mytab.append(mytr2); var btn=$() $("#mydiv").append(mytab); $("#mydiv").append(mytab2); // pageCurrent=$.query.get("pageindex"); if(pageCurrent==""){pageCurrent=1} //最后一页点击 $("#lastpage").click(function(){ //$(this).addClass("disable4"); pageCurrent = pagecount; show(pageCurrent - 1); }); //下一页点击 $("#nextpage").click(function(){ //$(this).addClass("disable4"); pageCurrent++; if (pageCurrent <= pagecount) //如果没有超出记录行数 { show(pageCurrent); } else { MessageBox.Show("现已是最后一页记录"); pageCurrent = pagecount; return; } }); //前一页点击 $("#prevpage").click(function(){ pageCurrent--; if (pageCurrent > 0) //如果当前不是首记录 { show(pageCurrent); //显示上一页记录 } else { MessageBox.Show("现已是第一页记录"); pageCurrent = 1; return; } }); //第一页点击 $("#firstpage").click(function(){ pageCurrent=1; show(pageCurrent ); }); } function clickme(id) { alert(id); } function show(pageCurrent){ $.ajax({ type:"post", dataType:"json", error:function(err,errstr){ alert("访问失败。"); }, url:"svr.aspx?pages="+pages+"&pageCurrent="+pageCurrent , success:function(data) { var count=data.count; var items=data.items; $("#mydiv").empty(); creatTable(items,count); } }); } </script> <style type="text/css">mytab,table{border:0px solid #336699}mytab,td{background-color: #DFC;border-bottom: 2px solid #B3DE94;border-top: 3px solid #FFFFFF;padding: 9px;overflow:hidden;white-space:nospace;text-overflow:ellipsis}</style></head><body> <div id="mydiv"> </div> <div style="display:none" id="div1"> <iframe src="http://www.baidu.com" name="123" width="10%" height="300" scrolling="auto" frameborder="0"></iframe> </div></body></html>这是我全部代码,您要不帮我看看哪里错了div 有ID 的document.getElementById('div1').style.display='block' 你的iframe可能宽度是个0,有反映页面看不到而已。 document.getElementById('div1').style.display='block'不是document.getElementById('123').style.display='block'ID错了 我这是想试试直接引用iframe改的,使您给的方法的时候改成了div1了刚才又改回去了,但还是不行 autocomplete,用jquery呼叫database里的资料。 小问题,你懂得!~~~~ 乱码问题 链接与图片的问题 javascript初学者关于二维数组输出的提问 我想知道正则表达式有不有一种方法来清除正则表达式的lastindex的值! 这里老是提示ibSpan为空或不是对象,为啥? 请问:这种情况如何改变字体颜色 jquery怎样给动态添加的元素绑定事件? 求一个正则表达式 求js实现网页背景图片定时变换的代码 快捷键绑定FORM表单按钮提交事件,失效问题,请教各位
<iframe src="http://www.baidu.com" name="123" width="10%" height="300" scrolling="auto" frameborder="0">
</div>
你要怎么弹出?我给的那个是将隐藏的div显示
循环创建的代码贴下
你要怎么弹出?我给的那个是将隐藏的div显示
循环创建的代码贴下
for (var i = 0; i < items.length; i++) {
mytr = $("<tr valign='center' ><td align='center' width:200px;height:30px;overflow:hidden;white-space:nowrap;text-overflow: ellipsis;>" + items[i].id + "</td></td><td width:350px;height:30px;white-space:nowrap;overflow:hidden; text-overflow:ellipsis;-webkit-text-overflow:ellipsis; onclick='clickme(\"" + items[i].nm + "\")'>" + items[i].nm + "</td><td width:20px;><button id='btn' value='click' onclick='document.getElementById('div1').style.display='block''>打开</button></td></tr>");
mytab.append(mytr);
}
<div style="display:none" id="div1">
我按您写的给加上了可是没有反映
<html>
<head id="Head1" runat="server"> <title>无标题页</title>
<script src="jquery-1.6.2.js"></script> <%--<script>--%>
<script type="text/javascript">
var pageCurrent=1,pagecount=0,count=0,pages=10;
var status="",id_Current=null,type="";var ad_Current="";
$(function(){
$.ajax({
type:"post",
dataType:"json",
error:function(err,errstr){
alert("访问失败。");
},
url:"svr.aspx" ,
success:function(data)
{ var count=data.count;
var items=data.items;
creatTable(items,count);
}
});
});
function creatTable(items,count){
if (pagecount == 0)
{
pagecount = Math.ceil(count / pages);
}
var mytab = $("<table cellspacing='1' cellpadding='0' style='width:700px; table-layout:fixed;overflow:hidden;white-space:nowrap; display: table;'></table>");
var mytr3 =$("<tr align='center'width:200px;height:30px; overflow:hidden;white-space:nowrap;><td align='center' style='width:200px;height:30px;overflow:hidden;white-space:nowrap;font-weight:bold;' >ID</td><td align='center' style='width:350px;height:30px;overflow:hidden;white-space:nowrap;font-weight:bold;'>名称</td><td></td></tr>")
mytab.append(mytr3);
for (var i = 0; i < items.length; i++) {
mytr = $("<tr valign='center' ><td align='center' width:200px;height:30px;overflow:hidden;white-space:nowrap;text-overflow: ellipsis;>" + items[i].id + "</td></td><td width:350px;height:30px;white-space:nowrap;overflow:hidden; text-overflow:ellipsis;-webkit-text-overflow:ellipsis; onclick='clickme(\"" + items[i].nm + "\")'>" + items[i].nm + "</td><td width:20px;><button id='btn' value='click' onclick='document.getElementById('123').style.display='block''>打开</button></td></tr>");
mytab.append(mytr);
}
var mytab2 =$(
"<table style='width:700px;'><tr><td><div id='_txtTotalCount'>共"+count+"条</div><div id='_pageTotal' >第"+pageCurrent+"页,共"+Math.ceil(pagecount)+"页</div></td></tr><tr valign='right' width:200px;height:30px><td id='td1' align='right'width:200px;height:30px> <img id='firstpage' src='../css/images/clear.gif' class='disable1' border='1' title='首页' alt='首页'> <img id='prevpage' class='disable2' border='1'src='../css/images/clear.gif' title='上一页' alt='上一页'> <img id='nextpage' class='enable3' border='1'src='../css/images/clear.gif' title='下一页' alt='下一页'> <img id='lastpage' class='enable4' border='1'src='../css/images/clear.gif' title='尾页' alt='尾页'></td></tr></table>");
// mytab.append(mytr2);
var btn=$()
$("#mydiv").append(mytab);
$("#mydiv").append(mytab2);
// pageCurrent=$.query.get("pageindex");
if(pageCurrent==""){pageCurrent=1}
//最后一页点击
$("#lastpage").click(function(){
//$(this).addClass("disable4");
pageCurrent = pagecount;
show(pageCurrent - 1);
});
//下一页点击
$("#nextpage").click(function(){
//$(this).addClass("disable4");
pageCurrent++;
if (pageCurrent <= pagecount) //如果没有超出记录行数
{
show(pageCurrent);
}
else
{
MessageBox.Show("现已是最后一页记录");
pageCurrent = pagecount;
return;
}
});
//前一页点击
$("#prevpage").click(function(){
pageCurrent--;
if (pageCurrent > 0) //如果当前不是首记录
{
show(pageCurrent); //显示上一页记录
}
else
{
MessageBox.Show("现已是第一页记录");
pageCurrent = 1;
return;
}
});
//第一页点击
$("#firstpage").click(function(){
pageCurrent=1;
show(pageCurrent
);
});
}
function clickme(id) { alert(id); }
function show(pageCurrent){
$.ajax({
type:"post",
dataType:"json",
error:function(err,errstr){
alert("访问失败。");
},
url:"svr.aspx?pages="+pages+"&pageCurrent="+pageCurrent ,
success:function(data)
{ var count=data.count;
var items=data.items;
$("#mydiv").empty();
creatTable(items,count);
}
});
}
</script> <style type="text/css">
mytab,table{border:0px solid #336699}
mytab,td{background-color: #DFC;
border-bottom: 2px solid #B3DE94;
border-top: 3px solid #FFFFFF;
padding: 9px;
overflow:hidden;
white-space:nospace;
text-overflow:ellipsis
}</style>
</head>
<body>
<div id="mydiv">
</div>
<div style="display:none" id="div1">
<iframe src="http://www.baidu.com" name="123" width="10%" height="300" scrolling="auto" frameborder="0"></iframe>
</div>
</body>
</html>这是我全部代码,您要不帮我看看哪里错了div 有ID 的document.getElementById('div1').style.display='block'
不是document.getElementById('123').style.display='block'
ID错了
刚才又改回去了,但还是不行