?? editor_find.asp
字號:
<HTML>
<HEAD>
<TITLE>查找 / 替換</TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
body, a, table, div, span, td, th, input, select{font-size:9pt;font-family: "宋體", Verdana, Arial, Helvetica, sans-serif;}
body {padding:5px}
</style>
<script language="JavaScript">
// 初始選定對象
var oSelection;
oSelection = dialogArguments.document.selection.createRange();
// 返回匹配條件
function searchtype(){
var retval = 0;
var matchcase = 0;
var matchword = 0;
if (document.frmSearch.blnMatchCase.checked) matchcase = 4;
if (document.frmSearch.blnMatchWord.checked) matchword = 2;
retval = matchcase + matchword;
return(retval);
}
// 檢測輸入
function checkInput(){
if (document.frmSearch.strSearch.value.length < 1) {
alert("請輸入查找內容");
return false;
} else {
return true;
}
}
// 查找
function findtext(){
if (checkInput()) {
var searchval = document.frmSearch.strSearch.value;
oSelection.collapse(false);
if (oSelection.findText(searchval, 1000000000, searchtype())) {
oSelection.select();
} else {
var startfromtop = confirm("搜索完成,是否要從頂部開始重新搜索?");
if (startfromtop) {
oSelection.expand("textedit");
oSelection.collapse();
oSelection.select();
findtext();
}
}
}
}
// 在選中的文本中替換
function replacetext(){
if (checkInput()) {
if (document.frmSearch.blnMatchCase.checked){
if (oSelection.text == document.frmSearch.strSearch.value) oSelection.text = document.frmSearch.strReplace.value
} else {
if (oSelection.text.toLowerCase() == document.frmSearch.strSearch.value.toLowerCase()) oSelection.text = document.frmSearch.strReplace.value
}
findtext();
}
}
// 在所有內容中替換
function replacealltext(){
if (checkInput()) {
var searchval = document.frmSearch.strSearch.value;
var wordcount = 0;
var msg = "";
oSelection.expand("textedit");
oSelection.collapse();
oSelection.select();
while (oSelection.findText(searchval, 1000000000, searchtype())){
oSelection.select();
oSelection.text = document.frmSearch.strReplace.value;
wordcount++;
}
if (wordcount == 0) msg = "要查找的內容沒有找到"
else msg = wordcount + " 處文本被替換成功";
alert(msg);
}
}
</script>
</HEAD>
<BODY bgcolor="menu">
<FORM NAME="frmSearch" method="post" action="">
<TABLE CELLSPACING="0" cellpadding="5" border="0">
<TR><TD VALIGN="top" align="left" nowrap>
<label for="strSearch">查找內容</label><br>
<INPUT TYPE=TEXT SIZE=40 NAME=strSearch id="strSearch" style="width : 200px;"><br>
<label for="strReplace">替換內容</label><br>
<INPUT TYPE=TEXT SIZE=40 NAME=strReplace id="strReplace" style="width : 200px;"><br>
<INPUT TYPE=Checkbox SIZE=40 NAME=blnMatchCase ID="blnMatchCase"><label for="blnMatchCase">區分大小寫</label><br>
<INPUT TYPE=Checkbox SIZE=40 NAME=blnMatchWord ID="blnMatchWord"><label for="blnMatchWord">全部匹配</label>
</td>
<td rowspan="2" valign="top">
<input type=button style="width:80px;margin-top:15px" name="btnFind" onClick="findtext();" value="查找下一個"><br>
<input type=button style="width:80px;margin-top:5px" name="btnCancel" onClick="window.close();" value="關閉"><br>
<input type=button style="width:80px;margin-top:5px" name="btnReplace" onClick="replacetext();" value="替換"><br>
<input type=button style="width:80px;margin-top:5px" name="btnReplaceall" onClick="replacealltext();" value="全部替換"><br>
</td>
</tr>
</table>
</FORM>
</BODY>
</HTML>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -