문서내 문자찾기
# Ctrl + F 기능
<script>
var NS4 = (document.layers);
var IE4 = (document.all);
var win = window;
var n = 0;
function findInPage(str){
var txt, i, found;
if (str == "") return false;
if (NS4) {
if (!win.find(str))
while(win.find(str, false, true))
n++;
else
n++;
if (n == 0)
alert("해당 문자를 찾을수가 없습니다.");
}
if (IE4) {
txt = win.document.body.createTextRange();
for (i = 0; i <= n && (found = txt.findText(str)) != false; i++) {
txt.moveStart("character", 1);
txt.moveEnd("textedit");
}
if (found) {
txt.moveStart("character", -1);
txt.findText(str);
txt.select();
txt.scrollIntoView();
n++;
}
else {
if (n > 0) {
n = 0;
findInPage(str);
}
else
alert("해당문자를 찾을수가 없습니다.");
}
}
return false;
}
</script>
<b>문자찾기 - 문자입력후 검색하면 해당 문자를 블럭처리하여 찾아줍니다.</b>
<form name="search" onSubmit="return findInPage(this.string.value);">
<input type="text" name="string" size="15" class="login_box" onChange="n = 0;">
<input type="submit" value=검색 align="top"></p>
</form>
<p>
동해물과 백두산이 마르고 닳도록 하느님이 보우아사 우리나라만세<br>
무궁화 삼천리 화려강산 대한사람 대한으로 길이 보전하세
</p>