Code
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>双击获得选中的内容</title>
<script language="javascript" type="text/javascript">
function dbclickfun()
{
if(window.getSelection) {
return window.getSelection().toString();
} else if(document.selection && document.selection.createRange) {
alert(document.selection.createRange().text);
}
}
</script>
</head>
<body>
<div ondblclick="dbclickfun()">你好 谢谢 再见</div>
</body>
</html>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>双击获得选中的内容</title>
<script language="javascript" type="text/javascript">
function dbclickfun()
{
if(window.getSelection) {
return window.getSelection().toString();
} else if(document.selection && document.selection.createRange) {
alert(document.selection.createRange().text);
}
}
</script>
</head>
<body>
<div ondblclick="dbclickfun()">你好 谢谢 再见</div>
</body>
</html>