Diff
checker
文本
文本
圖像
文檔
Excel
文件夾
Legal
Enterprise
桌面版
定價
登入
下載 Diffchecker 桌面版
比較文本
尋找兩個文字檔案之間的差異
工具
歷史
即時編輯器
摺疊未變更行
關閉換行
檢視
拆分
統一
比對精度
智能
單詞
字符
語法突出顯示
選擇語法
忽略
文字轉換
前往第一個差異
編輯輸入
Diffchecker Desktop
執行Diffchecker最安全的方式。取得Diffchecker桌面應用程式:您的差異永遠不會離開您的電腦!
取得桌面版
Untitled diff
建立於
11 年前
差異永不過期
清除
匯出
分享
解釋
1 刪除
行
總計
刪除
字符
總計
刪除
要繼續使用此功能,請升級到
Diff
checker
Pro
查看價格
39 行
全部複製
53 新增
行
總計
新增
字符
總計
新增
要繼續使用此功能,請升級到
Diff
checker
Pro
查看價格
90 行
全部複製
複製
已複製
複製
已複製
function blink() {
document.getElementById('caret').hidden ^= 1;
blinkTimeout = setTimeout(blink, 500);
}
var mydiv = document.getElementById('mydiv'),
var mydiv = document.getElementById('mydiv'),
複製
已複製
複製
已複製
myta = document.getElementById('myta')
;
myta = document.getElementById('myta')
,
blinkTimeout = setTimeout(blink, 500),
lastSelectionStart = 0,
lastSelectionEnd = 0,
whichSelection = true;
function updateDiv() {
function updateDiv() {
var fc;
var fc;
while (fc = mydiv.firstChild) mydiv.removeChild(fc);
while (fc = mydiv.firstChild) mydiv.removeChild(fc);
複製
已複製
複製
已複製
if (myta.selectionStart != lastSelectionStart) {
lastSelectionStart = myta.selectionStart;
whichSelection = false;
}
if (myta.selectionEnd != lastSelectionEnd) {
lastSelectionEnd = myta.selectionEnd;
whichSelection = true;
}
var cursorPos = whichSelection ? myta.selectionEnd : myta.selectionStart;
for (var i = 0; i < myta.value.length; i++) {
for (var i = 0; i < myta.value.length; i++) {
複製
已複製
複製
已複製
if (i == cursorPos) {
var caret = document.createElement('span');
caret.id = 'caret';
caret.appendChild(document.createTextNode('\xA0'));
mydiv.appendChild(caret);
clearTimeout(blinkTimeout);
blinkTimeout = setTimeout(blink, 500);
}
var span = document.createElement('span');
var span = document.createElement('span');
span.className = Math.random() < 0.5 ? 'green' : 'red';
span.className = Math.random() < 0.5 ? 'green' : 'red';
span.appendChild(document.createTextNode(myta.value[i]));
span.appendChild(document.createTextNode(myta.value[i]));
mydiv.appendChild(span);
mydiv.appendChild(span);
}
}
複製
已複製
複製
已複製
if (myta.value.length == cursorPos) {
var caret = document.createElement('span');
caret.id = 'caret';
caret.appendChild(document.createTextNode('\xA0'));
mydiv.appendChild(caret);
clearTimeout(blinkTimeout);
blinkTimeout = setTimeout(blink, 500);
}
};
};
myta.addEventListener('input', updateDiv);
myta.addEventListener('input', updateDiv);
複製
已複製
複製
已複製
myta.addEventListener('focus', updateDiv);
myta.addEventListener('mousedown', function() {
setTimeout(updateDiv, 0);
});
myta.addEventListener('keydown', function() {
setTimeout(updateDiv, 0);
});
myta.addEventListener('blur', function() {
document.getElementById('caret').hidden = true;
clearTimeout(blinkTimeout);
});
body { position: relative }
body { position: relative }
div, textarea {
div, textarea {
-webkit-text-size-adjust: none;
-webkit-text-size-adjust: none;
width: 100%;
width: 100%;
white-space: pre-wrap;
white-space: pre-wrap;
word-wrap: break-word;
word-wrap: break-word;
overflow-wrap: break-word;
overflow-wrap: break-word;
font: 1rem sans-serif;
font: 1rem sans-serif;
padding: 2px;
padding: 2px;
margin: 0;
margin: 0;
border-radius: 0;
border-radius: 0;
border: 1px solid #000;
border: 1px solid #000;
resize: none;
resize: none;
}
}
textarea {
textarea {
position: absolute;
position: absolute;
top: 0;
top: 0;
color: transparent;
color: transparent;
background: transparent;
background: transparent;
}
}
.red { color: #f00 }
.red { color: #f00 }
.green { color: #0f0 }
.green { color: #0f0 }
複製
已複製
複製
已複製
#caret {
display: inline-block;
position: absolute;
width: 1px;
background: #000;
}
#caret[hidden] { display: none }
複製
已複製
複製
已複製
<div id="mydiv"
></div>
<div id="mydiv"
><span id="caret"> </span
></div>
<textarea id="myta" autofocus=""></textarea>
<textarea id="myta" autofocus=""></textarea>
已保存差異
原始文本
開啟檔案
var mydiv = document.getElementById('mydiv'), myta = document.getElementById('myta'); function updateDiv() { var fc; while (fc = mydiv.firstChild) mydiv.removeChild(fc); for (var i = 0; i < myta.value.length; i++) { var span = document.createElement('span'); span.className = Math.random() < 0.5 ? 'green' : 'red'; span.appendChild(document.createTextNode(myta.value[i])); mydiv.appendChild(span); } }; myta.addEventListener('input', updateDiv); body { position: relative } div, textarea { -webkit-text-size-adjust: none; width: 100%; white-space: pre-wrap; word-wrap: break-word; overflow-wrap: break-word; font: 1rem sans-serif; padding: 2px; margin: 0; border-radius: 0; border: 1px solid #000; resize: none; } textarea { position: absolute; top: 0; color: transparent; background: transparent; } .red { color: #f00 } .green { color: #0f0 } <div id="mydiv"></div> <textarea id="myta" autofocus=""></textarea>
更改後文本
開啟檔案
function blink() { document.getElementById('caret').hidden ^= 1; blinkTimeout = setTimeout(blink, 500); } var mydiv = document.getElementById('mydiv'), myta = document.getElementById('myta'), blinkTimeout = setTimeout(blink, 500), lastSelectionStart = 0, lastSelectionEnd = 0, whichSelection = true; function updateDiv() { var fc; while (fc = mydiv.firstChild) mydiv.removeChild(fc); if (myta.selectionStart != lastSelectionStart) { lastSelectionStart = myta.selectionStart; whichSelection = false; } if (myta.selectionEnd != lastSelectionEnd) { lastSelectionEnd = myta.selectionEnd; whichSelection = true; } var cursorPos = whichSelection ? myta.selectionEnd : myta.selectionStart; for (var i = 0; i < myta.value.length; i++) { if (i == cursorPos) { var caret = document.createElement('span'); caret.id = 'caret'; caret.appendChild(document.createTextNode('\xA0')); mydiv.appendChild(caret); clearTimeout(blinkTimeout); blinkTimeout = setTimeout(blink, 500); } var span = document.createElement('span'); span.className = Math.random() < 0.5 ? 'green' : 'red'; span.appendChild(document.createTextNode(myta.value[i])); mydiv.appendChild(span); } if (myta.value.length == cursorPos) { var caret = document.createElement('span'); caret.id = 'caret'; caret.appendChild(document.createTextNode('\xA0')); mydiv.appendChild(caret); clearTimeout(blinkTimeout); blinkTimeout = setTimeout(blink, 500); } }; myta.addEventListener('input', updateDiv); myta.addEventListener('focus', updateDiv); myta.addEventListener('mousedown', function() { setTimeout(updateDiv, 0); }); myta.addEventListener('keydown', function() { setTimeout(updateDiv, 0); }); myta.addEventListener('blur', function() { document.getElementById('caret').hidden = true; clearTimeout(blinkTimeout); }); body { position: relative } div, textarea { -webkit-text-size-adjust: none; width: 100%; white-space: pre-wrap; word-wrap: break-word; overflow-wrap: break-word; font: 1rem sans-serif; padding: 2px; margin: 0; border-radius: 0; border: 1px solid #000; resize: none; } textarea { position: absolute; top: 0; color: transparent; background: transparent; } .red { color: #f00 } .green { color: #0f0 } #caret { display: inline-block; position: absolute; width: 1px; background: #000; } #caret[hidden] { display: none } <div id="mydiv"><span id="caret"> </span></div> <textarea id="myta" autofocus=""></textarea>
尋找差異