Loading....

HEAD

  • 有一种精神,叫"公诚勤朴"

挣点外快

获取鼠标选择的文本内容之JavaScript代码
作者: wzhu 时间: 2008-11-22 19:04:08

想研究划词翻译玩意, 做个演示Demo,其中无非就是使用到Ajax, 但主要问题是如何获取到用户划取得内容,然后发送给服务器翻译, 显示返回结果.

其中获取鼠标划取文本内容的JavaScript如下:

<script type="text/javascript">
function getSelectText()
{
    var txt = null;
    if (window.getSelection){  // mozilla FF
        txt = window.getSelection();
    }else if (document.getSelection){
        txt = document.getSelection();
    }else if (document.selection){  //IE
        txt = document.selection.createRange().text;
    }
    return txt;
}
</script>

效果演示区

As a result, I am pleased to announce a reorganization that will give some of our smaller business units greater scale. It will also allow us to integrate certain activities that we perform today in each unit into a country-wide organization. At the business level, we will consolidate six units into four: Healthcare, Consumer, Enterprise and Telecom (which now integrates Wireless) - all reporting to Sanjay Singh. We will also formalize the position of country heads in India, Ukraine and China - all reporting to Mukul Jain along with select global function heads. To be clear, these changes are not in anticipation of shrinkage but to better position us for growth. This new organization structure will ensure that our units are built around cohesive markets, which is good for our clients. It will also ensure that countries and product engineering centers will operate in a more integrated fashion, which is good for our employees. It will also support the more rapid adoption of global systems and processes. To learn more, please refer to the Re-organization Summary section below.

 

您选取的内容是:
相关评论
发表评论
姓名:
图码: