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>




  • 相关阅读:
    源码
    Leetcode 230. 二叉搜索树中第K小的元素 中序遍历
    Leetcode 160. 相交链表 哈希 链表
    Leetcode 142. 环形链表 II
    Leetcode 217. 存在重复元素 哈希 排序
    asp.mvc2.0资料
    关于CRM的介绍
    WPf控件模板缺省样式
    皮肤制作工具
    关于linq的用法
  • 原文地址:https://www.cnblogs.com/wangxiang/p/916356.html
Copyright © 2011-2022 走看看