<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$(".btn").click(function () {
$("#dd").html("<div class='div'><iframe border='0' width='100%' onload='SetWinHeight(this)' height='100%' src='1.html'></iframe><div class='close'>×</div></div>"); $(".close").click(function () {
$(".div").remove();
})
}) }); function SetWinHeight(obj) {
obj.style.height = obj.contentWindow.document.body.scrollHeight + 'px';
obj.style.width = obj.contentWindow.document.body.scrollWidth + 'px';
}
</script><style>
*{
margin:0;
padding:0;
}
.div{
position:absolute;
top:50px;
left:50px;
border:1px solid #06C;
}
</style>
</head>
<body>
<input class="btn" type="button" value="点击" />
<input class="text" type="text" />
<div id="dd"></div>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$(".btn").click(function () {
$("#dd").html("<div class='div'><iframe border='0' width='100%' onload='SetWinHeight(this)' height='100%' src='1.html'></iframe><div class='close'>×</div></div>"); $(".close").click(function () {
$(".div").remove();
})
}) }); function SetWinHeight(obj) {
obj.style.height = obj.contentWindow.document.body.scrollHeight + 'px';
obj.style.width = obj.contentWindow.document.body.scrollWidth + 'px';
}
</script><style>
*{
margin:0;
padding:0;
}
.div{
position:absolute;
top:50px;
left:50px;
border:1px solid #06C;
}
</style>
</head>
<body>
<input class="btn" type="button" value="点击" />
<input class="text" type="text" />
<div id="dd"></div>
</body>
</html>
解决方案 »
- 我想用JS写一个获取某个节点的父节点id的程序。但代码中的红色部分,即输入的参数不对,应该怎样把a标签的id参数传进去,然后获得其父节点div的id呢?
- ajax解析xml
- 【原创】图片(旋转/缩放/翻转)变换效果(ccs3/滤镜/canvas)
- 求助: javascript事件问题
- 求网站上在一个表格里显示多张图片
- form中的select控件当select内容改变,from中的textfeid值也改变
- 我想问下,如何实现弹出窗口不被类似TT及Firefox这样的浏览器所最大化?
- ie9,ie10里面如何取得tab页面的关闭动作?
- 求救啊.....超简单的一个问题..
- 为什么捕捉不到iframe里的event?急~~~~
- 求个正则表达式
- backbone 2个model,2个view的事件触发问题?
<iframe id="frame" border='0' width='100%' height='100%' src='表格1.html' onload="height()"></iframe>function height2(){
var frame = document.getElementById("frame");
var height;
if (frame.Document){
height = frame.Document.body.scrollHeight + 20 + "px";
}else{
height = frame.contentDocument.body.scrollHeight+ 20 + "px";
}
$(".div").css("height",height);
}
2.$(".div").remove();3.iFrame跨域传值,查一下就是。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>表格2</title>
<style type="text/css">
*{
margin:0;
padding:0;
}
body{
font-size:12px;
}
a{
text-decoration:none;
}
.bg_congtnet{
width:725px;
float:left;
border:1px solid #999999;
}.bg_congtnet_zhong{
width:725px;
float:left;
}
.bg_congtnet_zhong .zhong_td1{
width:40px;
height:24px;
text-align:center;
border-right:1px solid #D2D2D2;
border-bottom:1px solid #D2D2D2;
}
.bg_congtnet_zhong .zhong_td2{
width:155px;
height:24px;
text-align:center;
line-height:24px;
border-right:1px solid #D2D2D2;
border-bottom:1px solid #D2D2D2;
}
.bg_congtnet_zhong .zhong_td3,.bg_congtnet_zhong .zhong_td4{
width:130px;
height:24px;
line-height:24px;
border-right:1px solid #DCDCDC;
border-bottom:1px solid #D2D2D2;
}
.bg_congtnet_zhong .zhong_td3{
text-align:center;
}
.bg_congtnet_zhong .zhong_td4{
text-align:left;
}
</style>
</head>
<body>
<div class="bg_congtnet">
<div id="zhong_fux" class="bg_congtnet_zhong">
<table class="list" cellpadding="0" cellspacing="0" border="0">
<tbody>
<tr>
<td class="zhong_td1">1</td>
<td class="zhong_td2">姓名</td>
<td class="zhong_td3">女</td>
<td class="zhong_td4">22</td>
<td class="zhong_td4">1989-11-11</td>
<td class="zhong_td4">2012-12-31</td>
<td></td>
</tr>
<tr>
<td class="zhong_td1">2</td>
<td class="zhong_td2">姓名2</td>
<td class="zhong_td3">女</td>
<td class="zhong_td4">22</td>
<td class="zhong_td4">1989-11-11</td>
<td class="zhong_td4">2012-12-31</td>
<td></td>
</tr>
<tr>
<td><input type="button" value="确定" /></td>
</tr>
</tbody>
</table>
</div>
</div>
</body>
</html>
这里是我表格2的内容 请问下当我选择表格第一行的时候 点击确定 表格第二列的内容显示到<input class="text" type="text" />这种跨域传值应该怎么做啊
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>表格2</title>
<style type="text/css">
*{
margin:0;
padding:0;
}
body{
font-size:12px;
}
a{
text-decoration:none;
}
.bg_congtnet{
width:725px;
float:left;
border:1px solid #999999;
}
.bg_congtnet_zhong{
width:725px;
float:left;
}
.bg_congtnet_zhong .zhong_td1{
width:40px;
height:24px;
text-align:center;
border-right:1px solid #D2D2D2;
border-bottom:1px solid #D2D2D2;
}
.bg_congtnet_zhong .zhong_td2{
width:155px;
height:24px;
text-align:center;
line-height:24px;
border-right:1px solid #D2D2D2;
border-bottom:1px solid #D2D2D2;
}
.bg_congtnet_zhong .zhong_td3,.bg_congtnet_zhong .zhong_td4{
width:130px;
height:24px;
line-height:24px;
border-right:1px solid #DCDCDC;
border-bottom:1px solid #D2D2D2;
}
.bg_congtnet_zhong .zhong_td3{
text-align:center;
}
.bg_congtnet_zhong .zhong_td4{
text-align:left;
}
.focus{background:#f00;color:White;}
</style>
</head>
<body>
<div class="bg_congtnet">
<div id="zhong_fux" class="bg_congtnet_zhong">
<table class="list" cellpadding="0" cellspacing="0" border="0">
<tbody>
<tr>
<td class="zhong_td1">1</td>
<td class="zhong_td2">姓名</td>
<td class="zhong_td3">女</td>
<td class="zhong_td4">22</td>
<td class="zhong_td4">1989-11-11</td>
<td class="zhong_td4">2012-12-31</td>
<td></td>
</tr>
<tr>
<td class="zhong_td1">2</td>
<td class="zhong_td2">姓名2</td>
<td class="zhong_td3">女</td>
<td class="zhong_td4">22</td>
<td class="zhong_td4">1989-11-11</td>
<td class="zhong_td4">2012-12-31</td>
<td></td>
</tr>
<tr>
<td><input type="button" value="确定" onclick="setText()" /></td>
</tr>
</tbody>
</table>
<script>
var tr
parent.$('#zhong_fux tr', document).not(':last').click(function () {
parent.$('#zhong_fux tr', document).removeClass('focus');
tr = parent.$(this).addClass('focus');
});
function setText() {
if (!tr) alert('先选择行先')
else {
parent.$('input.text', parent.document).val(tr.find('td:eq(1)').text());
}
}
</script>
</div>
</div>
</body>
</html>重设iframe的宽和高用这个。。忘记xhtml申明问题了
function SetWinHeight(obj) {
obj.style.height = Math.max(obj.contentWindow.document.body.scrollHeight, obj.contentWindow.document.documentElement.scrollHeight) + 'px';
obj.style.width = Math.max(obj.contentWindow.document.body.scrollWidth, obj.contentWindow.document.documentElement.scrollWidth) + 'px';
}
if (!tr) alert('先选择行先')
else {
parent.$('input.text', parent.document).val(tr.find('td:eq(1)').text());
parent.$(".div", parent.document).remove();
}
}
都是基础的知识,多学点基础了