<form id = form1>
<div class="Btn" title="Paste" language="javascript" onclick="text1.focus();text1.document.execCommand('paste');" style="cursor:hand">
复制
</div>
<textarea name=text1></textarea>
</form>
<div class="Btn" title="Paste" language="javascript" onclick="text1.focus();text1.document.execCommand('paste');" style="cursor:hand">
复制
</div>
<textarea name=text1></textarea>
</form>
<HTML>
<HEAD>
<TITLE> Q2413389 </TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<META NAME="Generator" CONTENT="Microsoft Notepad">
<META NAME="Author" CONTENT="Topmonkey">
<META NAME="Keywords" CONTENT="http://expert.csdn.net/Expert/topic/2413/2413389.xml?temp=.4325983">
<META NAME="Description" CONTENT="Re: Q2413389"></HEAD><BODY bgcolor="#FFFFFF" leftmargin="0" topmargin="0">
<Table Width="50" Align="Center" Border="1">
<tr>
<td id=a> </td>
</tr>
</Table>
<Script Language="JavaScript">
<!--
var x,y;
document.onmousemove = get_xy;
function get_xy(){
x=event.x;
y=event.y;
a.innerHTML="x="+x+"<br/>y="+y;
}
//-->
</Script>
</BODY>
</HTML>
<input id=t1 type=text>
<input type=button value="select text before clicking me" onclick="t1.select();document.execCommand('Paste')">
<html>
<head>
<style>
#ie5menu
{
position:absolute;
width:30px;
border:1px solid green;
background-color:menu;
font-family:Verdana;
font-size:9pt;
line-height:15px;
cursor:hand;
visibility:hidden;
} .menuitems
{
padding-left:5px;
padding-right:5px;
width:65;
height: 25
} </style>
<script language="JavaScript">
//set this variable to 1 if you wish the URLs of
//the highlighted menu to be displayed in the status bar
var display_url=0
var oTempRange=null;
var xx ;
var yy ;
var newtxt ;
function showmenuie5()
{var rightedge=document.body.clientWidth-event.clientX ;xx = event.x;
yy=event.y;
var bottomedge=document.body.clientHeight-event.clientY ;
if(rightedge<ie5menu.offsetWidth){
ie5menu.style.left=document.body.scrollLeft+event.clientX-ie5menu.offsetWidth ;
}else{
ie5menu.style.left=document.body.scrollLeft+event.clientX ;
}
if(bottomedge<ie5menu.offsetHeight){
ie5menu.style.top=document.body.scrollTop+event.clientY-ie5menu.offsetHeight ;
}else{
ie5menu.style.top=document.body.scrollTop+event.clientY ;
ie5menu.style.visibility="visible" ;
return false ;
}
}function hidemenuie5(){
if(document.selection.type=="Text"){
oTempRange=document.selection.createRange();
} ie5menu.style.visibility="hidden"
}function highlightie5()
{
if(event.srcElement.className=="menuitems")
{
event.srcElement.style.cursor="hand"
event.srcElement.style.backgroundColor="highlight"
event.srcElement.style.color="red"
}else {
event.srcElement.style.cursor="default"
}
} function lowlightie5()
{
if (event.srcElement.className=="menuitems"){
event.srcElement.style.backgroundColor=""
event.srcElement.style.color="black"
document.firstChild.window.status='' }}function copyText(){ var result = oTempRange.text;
var bResult = window.clipboardData.setData("Text",result);
}
function copyHtml(){ var result = oTempRange.htmlText;
var bResult = window.clipboardData.setData("Text",result);
}
function paste(){
document.location.reload();
// oTempRange.execCommand("paste");
newtxt=document.createElement("<span style='position:absolute;z-index:0;left:"+xx+";top:"+yy+";'></span>");
var clipResult = window.clipboardData.getData("Text");
// newtxt.innerText=clipResult;
newtxt.innerHTML=clipResult
// clipResult = clipResult.replace(/</i,"<");
// clipResult = clipResult.replace(/>/i, ">");
// newtxt.outerHTML = clipResult;
body1.appendChild(newtxt);
var head = document.firstChild.firstChild.outerHTML;
var hm = document.body.outerHTML;
hm = "<html>"+head+hm+"</html>";
document.removeChild(document.firstChild);
//var win = window.open("http://192.168.2.31:7001", "","");
document.write(hm);
// window.close();
}
function cutText(){
var result = oTempRange.text;
window.clipboardData.setData("Text","");
oTempRange.execCommand("paste"); var bResult = window.clipboardData.setData("Text",result);
}
function cutHtml(){
var result = oTempRange.htmlText;
window.clipboardData.setData("Text","");
oTempRange.execCommand("paste");
var bResult = window.clipboardData.setData("Text",result);
}
</script>
</head><body id="body1"><div id="ie5menu"><div class="menuitems" onClick="copyText()" >Copy(T)</div>
<div class="menuitems" onClick="copyHtml()" >Copy(H)</div>
<HR align=center width="65" size="1">
<div class="menuitems" onClick="cutText()" >Cut(T)</div>
<div class="menuitems" onClick="cutHtml()" >Cut(H)</div>
<HR align=center width="65" size="1">
<div class="menuitems" onClick="paste()" >Paste</div></div><p id="p">
点击右键打开菜单<br>
<form>
<span style='position: absolute; z-index: 0; left: 148; top: 16'> <input type="text" name=txtSearch value="dddd"></span>
<input type=button value=Copy2Clip onclick='javascript: var textRange=txtSearch.createTextRange(); textRange.execCommand("Copy")'>
<input type=button value=PastefromClip onclick='javascript: var textRange=txtSearch.createTextRange(); textRange.execCommand("Paste")'>
</form>
</p>
<div id=a></div>
</body> <script language="javascript">
document.oncontextmenu=showmenuie5
if (document.all && window.print)
document.body.onclick=hidemenuie5;
</script>
<Script Language="JavaScript">
<!--
var x,y;
var moveobj ;
var tempx,tempy,ckleft,cktop;
document.onmousedown= get_down;
body1.onmousemove = get_xy;
function get_xy(){
tempx=event.clientX ;
tempy=event.clientY;
//a.innerHTML="x="+tempx+"<br/>y="+tempy;
if(moveobj !=null){
moveobj.style.left=parseInt(tempx)-parseInt(ckleft);
moveobj.style.top=parseInt(tempy)-parseInt(cktop);
}
moveobj=null;
}
function get_down(){ x=event.x;
y=event.y;
if(event.srcElement.parentElement.id=="body1"){
moveobj=event.srcElement;
if(moveobj !=null){
if(!isNaN(parseInt(moveobj.style.left))){
ckleft=parseInt(x)-parseInt(moveobj.style.left);
}else {
ckleft=x;
}
if(!isNaN(parseInt(moveobj.style.top))){
cktop=parseInt(x)-parseInt(moveobj.style.top);
}else {
cktop=y;
}
}
}
}
//-->
</Script>
</html>
----------------------------------------------------------
<table>
<tr>
<td>
<input onclick="showDiv(this)">
</td>
</tr>
</table>
<div id=demo style="position:absolute;z-index:1000;visibility:hidden">hehe</div>
<script language="JavaScript">
<!--
function showDiv(o){
var e = o
var l = e.offsetLeft;
var t = e.offsetTop;
while(e = e.offsetParent){
l += e.offsetLeft;
t += e.offsetTop;
}
with(demo.style){
left = l
top = t+o.offsetHeight
width = o.offsetWidth
height = 100;
border = "1px outset"
visibility = visibility==''?'hidden':''
}
}
//-->
</script>
function doPaste()
{ obj=document.createElement("div");
document.body.appendChild(obj);
obj.style.position="absolute";
obj.style.top=event.clientY;
obj.style.left=event.clientX;
obj.style.width="100px";
obj.style.height="100px";
obj.innerText=clipboardData.getData("Text");}
</script>
<body onkeydown="if(event.ctrlKey&&event.keyCode==86)doPaste();">