반응형
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- 아이폰 리부팅
- 11g
- Java
- 아이폰
- 버츄오 할인
- 아이폰15 출시일
- Listener
- 네스프레소 버츄오 넥스트
- 모델S
- 3.1.3
- 해외직구 우편번호
- 원격데스크톱
- 쿠팡 네스프레소 할인
- 아이폰 강제 리부팅
- 아이폰 강제 재시동
- 삼성카드 우편번호
- 삼성카드 해외직구 우편번호
- 다운그레이드
- 카메라 격자 보이기
- oracle
- 원격데스크탑
- Util
- ZIP code does not match billing address
- 윈도우
- 모델x
- 삼성카드 해외직구
- 10g
- win7
- JSP
- 레드햇
Archives
- Today
- Total
starland
마우스로 드래그해서 선택한 텍스트 가져오기 본문
반응형
개발자는 아니지만 왠지 퍼다놓으면 언젠간 쓸일이 있을것 같아서...ㅡㅡ;;
===============================================================================================
마우스로 드래그해서 선택한 텍스트 가져오기
script 2009/09/04 15:23어떤 사이트들에서는 페이지의 텍스트를 드래그해서 선택한 후 바로 검색을 할 수 있게 만든 기능들이 있다.
그래서 그 기능의 핵심인 선택한 텍스트를 가져오는 스크립트를 만들어 보았다.
데모
abcdefghijklmnopqrstuvwxyz
그래서 그 기능의 핵심인 선택한 텍스트를 가져오는 스크립트를 만들어 보았다.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
#console { width: 300px; height: 20px; border: 1px solid #ccc; }
</style>
<script type="text/javascript">
function selectText() {
var selectionText = "";
if (document.getSelection) {
selectionText = document.getSelection();
} else if (document.selection) {
selectionText = document.selection.createRange().text;
}
return selectionText;
}
document.onmouseup = function() {
document.getElementById("console").innerHTML = selectText();
}
</script>
</head>
<body>
<p>abcdefghijklmnopqrstuvwxyz</p>
<p>마우스로 드래그해서 선택한 글 나오기</p>
<div id="console"></div>
</body>
</html>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
#console { width: 300px; height: 20px; border: 1px solid #ccc; }
</style>
<script type="text/javascript">
function selectText() {
var selectionText = "";
if (document.getSelection) {
selectionText = document.getSelection();
} else if (document.selection) {
selectionText = document.selection.createRange().text;
}
return selectionText;
}
document.onmouseup = function() {
document.getElementById("console").innerHTML = selectText();
}
</script>
</head>
<body>
<p>abcdefghijklmnopqrstuvwxyz</p>
<p>마우스로 드래그해서 선택한 글 나오기</p>
<div id="console"></div>
</body>
</html>
데모
abcdefghijklmnopqrstuvwxyz
마우스로 드래그해서 선택한 글 나오기
반응형
'짬통' 카테고리의 다른 글
[짬통] 단체선물 살만한 사이트 (0) | 2009.12.08 |
---|---|
[짬통] 연말정산 정보 펌 (0) | 2009.12.06 |
P5K (ASUS 메인보드) Sound 드라이버 안잡힐때 (0) | 2009.11.08 |
[WIN7] 문제 재현을 위한 단계기록 / Problem Steps Recoder 기능 (0) | 2009.11.07 |
개발 추천 폰트 (1) | 2009.11.02 |