문서내의 특정 단어를 한꺼번에 찾아 배경색을 다르게 표시해 줍니다 > script

본문 바로가기

script

문서내의 특정 단어를 한꺼번에 찾아 배경색을 다르게 표시해 줍니다

작성일 07-08-08 11:26

페이지 정보

작성자서방님 조회 170회 댓글 0건

본문

문서내의 특정 단어를 한꺼번에 찾아 배경색을 다르게 표시해 줍니다

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=euc-kr">
<title> jasko sample script </title>
</head>

[1단계] 아래의 스크립트를 <body></body> 사이에 붙여 넣으세요

<script language="javascript">
<!--
function Find() {

jaskoFind={
        x:function(){
                var r,i,s=document.selection.createRange().text;
                if(!s)s=prompt('찾을글자는요?:','JASKO'); // 기본적으로 질문할 내용과 찾을 단어를 수정 하세요
                if(s){
                        r=document.body.createTextRange();
                        for(i=0;r.findText(s);i++){
                        r.execCommand('BackColor','','yellow'); // 찾은 단어의 배경색상을 수정할 수 있습니다
                        r.collapse(false)
                }
                alert(i+" 개를 찾았습니다")
                }
        }
}

jaskoFind.x()

}
//-->
</script>

[2단계] 아래 태그를 원하는 위치에 붙여 넣으세요

<input type="button" name="button1" onclick="Find()" value=" 문서내에서 검색 ">

[3단계] 본문을 입력 합니다

JASKO 는 자바스크립트 소스뱅크 입니다<br>자스코에는 매일매일 업데이트 되는 5,000 개 이상의 자바스크립트와 애플릿, CGI 등등의 소스들이 있습니다<br>자바스크립트 소스가 필요하면 언제라도 JASKO 를 찾아주세요<br>
JavaScript Source Bank - JASKO

</body>
</html>

 

출처 : Jasco

댓글목록

등록된 댓글이 없습니다.

게시물 검색
Copyright © 서방님.kr All rights reserved.
PC 버전으로 보기