zoukankan      html  css  js  c++  java
  • 测试划词搜索代码

    <script>

    document.body.onload 
    = tt;
    function tt()
    {
    alert('dddddddd');
    }
    var b;

    function te() //onselect事件
    {
    b
    =1;
    }

    function a() //onmouseup事件
    {
    if (b==1){
    alert(document.selection.createRange().text);
    b
    =0;
    }
    }
    </script>
    <body onselect ="javascript:te();" onmouseup ="javascript:a();">
     onselectstart ="alert('开始');"
    onmouseup="alert(document.selection.createRange().text);"
    //firefox使用 window.getSelection()
    网页测试测试测试才儿时才扼杀
    <br>
    dddddddddddddddd
    <SCRIPT   LANGUAGE="JavaScript">   
      
    function   SelText(){   
      document.selection.createRange();   
      document.all.TestText.value   
    =   unescape(document.selection.createRange().text);   
    alert(
    "选区左侧宽度:"+ document.selection.createRange().boundingLeft);
    alert(
    "选区上方高度:" + document.selection.createRange().boundingTop);
    alert(
    "选区高度:" + document.selection.createRange().boundingHeight);
    alert(
    "选区宽度:" + document.selection.createRange().boundingWidth);
      }   
      
    </script>   
      
    <input   type="text"   id="TestText"   name="TestText"   value=""   accesskey="A">   
      
    <input   type="button"   name="btnTest"   value="Test"   onclick="SelText()">
    <hr>


    对象: document.selection.createRange();  返回TextRange 对象
    <br>

    TextRange 属性
    <br>


    boundingHeight 获取绑定 TextRange 对象的矩形的高度。 
    <br>
    boundingLeft 获取绑定 TextRange 对象的矩形左边缘和包含 TextRange 对象的左侧之间的距离。 
    <br>
    boundingTop 获取绑定 TextRange 对象的上边缘和包含 TextRange 对象的顶边之间的距离。 
    <br>
    boundingWidth Retrieves the width of the rectangle that bounds the TextRange object.  
    <br>
    htmlText 获取绑定 TextRange 对象的矩形的宽度。 
    <br>
    offsetLeft 获取对象相对于版面或由 offsetParent 属性指定的父坐标的计算左侧位置。
    <br> 
    offsetTop 获取对象相对于版面或由 offsetTop 属性指定的父坐标的计算顶端位置。 
    <br>
    text 设置或获取范围内包含的文本。 
    <br>
    </body>




  • 相关阅读:
    python读取.mat文件
    numpy.random.randint
    python小括号( )与中括号 [ ]
    cv2
    python matplotlib.pyplot画矩形图 以及plt.gca()
    python matplotlib.pyplot对图像进行绘制
    项目中遇到的问题
    菜鸟学习Spring——60s学会Spring与Hibernate的集成
    菜鸟nginx源代码剖析数据结构篇(九) 内存池ngx_pool_t
    c 语言函数可变參数的处理
  • 原文地址:https://www.cnblogs.com/wangxiang/p/916356.html
Copyright © 2011-2022 走看看