📄 finddialog.js
字号:
// JScript 文件
var EditorFrame = window.dialogArguments;
var FindRange = EditorFrame.document.body.createTextRange();
function Find(direction)
{
var bFound = false;
var TextFind = document.getElementById("TextFind");
if (TextFind.value == "")
{
alert("请输入要查找的内容");
}
else
{
var iFlags = 0 ;
if ( ChkCase.checked )
iFlags = iFlags | 4 ;
if ( ChkWord.checked )
iFlags = iFlags | 2 ;
bFound = FindRange.findText(TextFind.value, direction, iFlags ) ;
if (bFound)
{
FindRange.scrollIntoView() ;
FindRange.select() ;
FindRange.collapse(false) ;
}
else
{
FindRange = EditorFrame.document.body.createTextRange();
}
}
return bFound;
}
function Replace()
{
Find(0);
if (EditorFrame.document.selection != null)
{
var selectedtext = EditorFrame.document.selection.createRange().text;
if (selectedtext.length > 0)
{
if (selectedtext != document.getElementById("TextFind").value)
{
FindRange = EditorFrame.document.body.createTextRange();
}
EditorFrame.document.selection.createRange().text = document.getElementById("TextReplace").value;
}
}
Find(1);
}
function ReplaceAll()
{
FindRange = EditorFrame.document.body.createTextRange();
var count = 0;
while(Find(1))
{
count++;
EditorFrame.document.selection.createRange().text = document.getElementById("TextReplace").value;
}
if (count > 0)
{
alert("操作完成,共完成替换" + count + "处内容");
}
else
{
alert("操作失败,未找到任何待替换数据");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -