在我的HTML页面中有很多处我高亮显示的文字。我想当我鼠标双击某个高亮显示的地方的时候我要实现:1.获取我双击的对象(高亮显示的文字)2。打开一个新窗体,我双击的对象传到这个新的窗体上

解决方案 »

  1.   

    //default.aspx的代码 
    <input type="button" value="模式对话框" id="btn" onclick="returnModel(this.value)" />
      function returnModel(obj) {
                var objs = new Object();
                objs.name =obj;
               
               var returnObject = window.showModalDialog("ModelDialog.aspx", objs, 'dialogHeight=200px;dialogWidth=100px;');
                           
            }
    //以下是ModelDialog.aspx页面的JS
       <script type="text/javascript">
                window.onload = function() {
                    var obj = window.dialogArguments;
                    alert("您传递的参数为:" + obj.name);            }
        
        </script>
      

  2.   

    html:
    <span ondblclick="test(this)">高亮显示的文字</span> js:
    function test(obj) {
       window.open("Default.aspx?a=" + obj.innerText);
    }页面接受c#:
            if (Request.QueryString["a"] != null)
                Response.Write(Request.QueryString["a"].ToString());
      

  3.   


    <!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></title>    <script src="jquery-1.4.2.js" type="text/javascript"></script>
        <script type="text/javascript">
            $(function() {
            $(".red span").dblclick(function() {
            //alert($(this).html());
            window.open("J1.htm?on=" + $(this).html());            });
            })
        </script>
        <style type="text/css">
            .red
            {
                color: Red;
            }
        </style>
    </head>
    <body>
        <div class="red">
            <span>点击1</span><span>点击2</span><span>点击3</span><span>点击4</span><span>点击5</span>
        </div>
    </body>
    </html>
      

  4.   

    其实也就是一个ondblclick事件而已~至于传值的方式那就太多了~感谢大家,很快结贴