you could only run this page in IE.and there is a problem, all right?let me review it, I'll try me best to help you. please wait a moment.

解决方案 »

  1.   

    I suggest that you can't get the value of the string your selected because ofwhen your right-button down, and click add, the selected string was clean out.
    then select event ended. so you should save the value when your right-button down even when selected.that's my suggestion.  you can send mail to me: [email protected]
      

  2.   

    <!-- done it. --><HTML><HEAD><TITLE>右键菜单的淡入淡出效果</TITLE>
    <META content="text/html; charset=gb2312" http-equiv=Content-Type>
    <SCRIPT language=JavaScript>
    <!-- // RightClickMenu
    var intDelay=10; //设置菜单显示速度,越大越慢
    var intInterval=5; //每次更改的透明度var content=null; // I add a node herefunction showmenuie5(){content=document.selection.createRange();  // on right-button down I do itvar rightedge=document.body.clientWidth-event.clientX
    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"
    //ie5menu.style.visibility=""
    ie5menu.filters.alpha.opacity=0
    GradientShow()
    return false
    }
    function hidemenuie5(){
    //ie5menu.style.visibility="hidden"
    GradientClose()
    }
    function highlightie5(){
    if (event.srcElement.className=="menuitems"){
    event.srcElement.style.backgroundColor="highlight"
    event.srcElement.style.color="white"
    }
    }
    function lowlightie5(){
    if (event.srcElement.className=="menuitems"){
    event.srcElement.style.backgroundColor=""
    event.srcElement.style.color="#000000"
    }
    }
    function jumptoie5(){
    if (event.srcElement.className=="menuitems"){
    if (event.srcElement.url != ''){
    if (event.srcElement.getAttribute("target")!=null)
    window.open(event.srcElement.url,event.srcElement.getAttribute("target"))
    else
    window.location=event.srcElement.url
    }
    }
    }function GradientShow() //实现淡入的函数
    {
    ie5menu.filters.alpha.opacity+=intInterval
    if (ie5menu.filters.alpha.opacity<100) setTimeout("GradientShow()",intDelay)
    }function GradientClose() //实现淡出的函数
    {
    ie5menu.filters.alpha.opacity-=intInterval
    if (ie5menu.filters.alpha.opacity>0) {
    setTimeout("GradientClose()",intDelay)
    }
    else {
    ie5menu.style.visibility="hidden"
    }
    }function ChangeBG() //改变菜单项的背景颜色,这里的两种颜色值可以改为你需要的
    {
    oEl=event.srcElement
    if (oEl.style.background!="navy") {
    oEl.style.background="navy"
    }
    else {
    oEl.style.background="#cccccc"
    }
    }
    // -->
    </SCRIPT><STYLE type=text/css>
    .cMenu {
    FILTER: alpha(opacity=0);BACKGROUND-COLOR: #D6D3CE;BORDER-BOTTOM: #666666 2px solid; BORDER-LEFT: #E4E4E4 2px solid; BORDER-RIGHT: #666666 2px solid; BORDER-TOP: #E4E4E4 2px solid; COLOR: #000000; CURSOR: default; FONT-SIZE: 9pt; color:#000000;FONT-WEIGHT: normal; LINE-HEIGHT: 20px; POSITION: absolute; VISIBILITY: hidden; WIDTH: 110px
    }
    .menuitems {
    font-size:9pt;
    MARGIN: 2px;
    PADDING-BOTTOM: 0px;
    PADDING-LEFT: 15px;
    PADDING-RIGHT: 3px;
    PADDING-TOP: 0px;
    }
    </STYLE><META content="Microsoft FrontPage 4.0" name=GENERATOR>
    </HEAD>
    <BODY>
    <OBJECT classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 id=WebBrowser width=0>
    </OBJECT>
    <RIGHTCLICK><!--[if IE]>
    <DIV class=cMenu id=ie5menu onclick=jumptoie5() onmouseout=lowlightie5()
    onmouseover=highlightie5()>
    <DIV class=menuitems url="javascript:AddTerm()">add</DIV></DIV>
    <![endif]--><SCRIPT language=JavaScript>
    <!--
    /*******************************change this function******************************/
    function AddTerm() {
    var s=(content==null)?document.selection.createRange().text:content.text;
    var x=(content==null)?document.selection.createRange():content;
    content=null;
    x.execCommand("ForeColor",false,"red") ;
    myform.termarea.value= myform.termarea.value+s;
    }
    /************************************no change below*******************************/if (document.all&&window.print){
    ie5menu.className="cMenu";
    document.oncontextmenu=showmenuie5;
    document.body.onclick=hidemenuie5;
    }
    //-->
    </SCRIPT>
    </RIGHTCLICK>
    <form name="myform">
    选中我!
    <br>
    <textarea cols="100" rows="10" name="termarea"></textarea>
    <br />
    <input type="button" name="button1" value="AddTerm" onClick="AddTerm()"></form>
    </BODY>
    </HTML>
    <!--
    I've changed some code
    -->