这个作品中,重要的一点是只已经jQuery的从主窗口中引用不弹出窗口并控制从那里
弹出
主窗口
<!DOCTYPE html>
<html>
<head>
<title>Main Window</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
$(".editable").click(function() {
var
$element = $(this),
popupWindow = window.open("popup.html", "popup", "width=525,height=250");
$(popupWindow).load(function() {
var
$editor = $(popupWindow.document).find("#Editor"),
$submit = $(popupWindow.document).find("#Submit");
$editor.val($element.html());
$submit.click(function() {
$element.html($editor.val());
popupWindow.close();
});
});
popupWindow.element = this;
});
});
</script>
</head>
<body>
<div class="editable">
<p>I'm editable click me</p>
</div>
<div class="editable">
<p>I'm editable as well click me</p>
</div>
</body>
</html>
弹出窗口
<!DOCTYPE html>
<html>
<head>
<title>Popup Window</title>
</head>
<body>
<textarea id="Editor" rows=10 cols=60></textarea>
<input id="Submit" value="Submit" type="button" />
</body>
</html>
注意:JSON是一个字符串而不是对象......您可以将JSON字符串解析为JavaScript对象...... – ManseUK 2012-03-20 15:16:34