copy and past code in a.html file.
must replace ' / ' to ' < ' then run.
save in same dir .html and .txt file.
/html>
/head>
/script language="JavaScript" type="text/javascript">
function fetchText(txtFile) {
var d = document;
var txtFrame = d.getElementById( 'textReader');
txtFrame.src = txtFile;
var text = '';
if (txtFrame.contentDocument) {
var d = txtFrame.contentDocument;
text = d.getElementsByTagName( 'BODY')[ 0].innerHTML;
}
else if (txtFrame.contentWindow) {
var w = txtFrame.contentWindow;
text = w.document.body.innerHTML;
}
return text;
}
function doTest( ) {
var fl=document.f.file.value;
var txt = fetchText(fl);
var tt=document.f.t.value;
var is = (-1 != txt.indexOf(tt))?' >':'> not';
alert('string is <'+ tt + is + ' found');
}
a.txt
this is a txt file, you find any string from this file. your content are written in this file. it is case sensitive search.
No comments:
Post a Comment