开启一个新的浏览器窗口保留未编辑完内容

本文介绍了一种在邮件系统中实现未完成邮件内容在新窗口中继续编辑的方法。通过JavaScript实现弹出新窗口并复制当前编辑内容的功能。

问题:

在邮件系统中写新邮件或者回复邮件时,我们一般会在主界面上直接编辑邮件内容,如果邮件还没有编辑完成,我们却需要查看其他邮件,这时就要开启一个新窗口保留未编辑完的邮件内容。

解决方案:

ContractedBlock.gifExpandedBlockStart.gifCode
//1.html
<!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>
    
<title>1</title>
    
<script type="text/javascript">
    
function editInNewWin()
    {
    
var win = window.open("2.html","_blank","width=400,height=300");
    }
    
</script>
    
<style type="text/css">
      #editor 
{width: 300px}
      #title, #editor textarea
{width: 100%;height: 80%}
    
</style>
</head>

<body>
  
<form action=#>
    
<div id=editor>
      标题:
<input type="text" id="title">
      内容:
<textarea cols=30 rows=5 id=content></textarea>
      
<input type=button value="提交">
      
<input type=button value="在新窗口中编辑" onclick="editInNewWin()">
    
</div>
  
</form>
</body>
ContractedBlock.gifExpandedBlockStart.gifCode
//2.html
<!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>
    
<title>2</title>
    
<script type="text/javascript">
    
function init()
    {
    
var oldPage = window.opener;
    
if(!parent) return;

    $(
"title").value = oldPage.document.getElementById("title").value;
    $(
"content").value = oldPage.document.getElementById("content").value;
    }

    
function $(id){
     
return document.getElementById(id);
    }
    
</script>
    
<style type="text/css">
      #editor 
{width: 300px}
      #title, #editor textarea
{width: 100%;height: 80%}
    
</style>
</head>
<body onload="init()">
  
<form action="#">
    
<div id="editor">
      标题:
<input type="text" id="title">
      内容:
<textarea cols=30 rows=5 id=content></textarea>
      
<input type=button value="提交">
      
    
</div>
  
</form>
</body>
</html>

转载于:https://www.cnblogs.com/lolicon/archive/2009/01/13/1374951.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值