在html中如何使用show modal dialog()实现以下功能?

html-css029

在html中如何使用show modal dialog()实现以下功能?,第1张

父页:

<script type="text/javascript">

<!--

function test(){

var returnValue = window.showModalDialog('Noname2.html')//这个URL可以是一个方法,也可以是一个页面,到页面用ajax去加载一个列表都可以

alert(returnValue)//取到值,你随便放哪里,

}

//-->

</script>

<body>

<table>

<tr>

<td><input type="text" name="nama" id="id"></td>

</tr>

<tr>

<td><input type="button" value="button" onclick='test()'></td>

</tr>

</table>

子页面:

<script type="text/javascript">

<!--

function fff(val){

//window.opener.window.returnVaule="ok"

window.returnValue = "ok"

}

function onload(){

$.ajax({

url : "你的方法",

type : "POST",

contentType: "application/jsoncharset=utf-8",

data : JSON.stringify({'name':name,'passwd':passwd}),

dataType : "text",

success : function(result) {

结果进行循环给列表,查下也是一样的,都调用这个方法

},

error:function(msg){

$(".notice").html('Error:'+msg)

}

})

}

onload()//第一次进来后调用一次加载列表

//-->

</script>

<body>

//这个TABLE可以用你自己的方法去写.比如请求后台加载的一个LIST数据,用ajax加载

//查下条件和你平时的页面是一样的,如果数据少,可以直接用数组来做

<table border=1>

<tr>

<td onclick="fff(1)">1</td>

<td onclick="fff(2)">2</td>

</tr>

</table>

modal 绑定ajax数据源:

1、html定义如下:

<div class="modal-dialog">

<div class="modal-content">

<div class="modal-header">

<button type="button" class="close" data-dismiss="modal">×</button>

<h4 class="modal-title"></h4>

</div>

<div class="modal-body">

</div>

<div class="modal-footer">

<a href="#" class="btn btn-white" data-dismiss="modal">Close</a>

<a href="#" class="btn btn-primary">Button</a>

<a href="#" class="btn btn-primary">Another button...</a>

</div>

</div><!-- /.modal-content -->

</div><!-- /.modal-dialog -->

2、modal中绑定数据源写法:

$('[data-toggle="ajaxModal"]').on('click',

function(e) {

$('#ajaxModal').remove()

e.preventDefault()

var $this = $(this)

, $remote = $this.data('remote') || $this.attr('href')

, $modal = $('<div class="modal" id="ajaxModal"><div class="modal-body"></div></div>')

$('body').append($modal)

$modal.modal({backdrop: 'static', keyboard: false})

$modal.load($remote)

}

)