hi
I Made A Code That Searches In A Text Area For A Specific Text And Highlights It (In IE The Text Area Scrolls Down Automatically To The Highlighted Text) But In FireFox It Doesn't . . How Can I Make It Scroll Down To The Selected Area My Code Is below :
** Assuming That $()=document.getElementById()
** Also Assuming That The id of the TextArea is "deisng_file_html"
function high_light(search_word){
$('design_file_html').value = $('design_file_html').value.replace(/(\r\n)*/g, "");
$('design_file_html').value = $('design_file_html').value.replace(/(\n)*/g, "");
var sel_start=$('design_file_html').value.indexOf(search_word);
if(sel_start==-1)
{
sel_start=0;
var sel_end=0;
}else{
sel_end=sel_start+search_word.length;
}
if(typeof($('design_file_html').selectionStart)=='number') {
$('design_file_html').focus();
$('design_file_html').select();
$('design_file_html').selectionStart = sel_start;
$('design_file_html').selectionEnd = sel_end;
} else if(document.selection && document.selection.createRange) {
$('design_file_html').focus();
$('design_file_html').select();
var rng2 = document.selection.createRange();
rng2.collapse();
rng2.moveStart('character',$('design_file_html').value.indexOf(search_word));
rng2.moveEnd('character',search_word.length);
rng2.select();
}
}
I Made A Code That Searches In A Text Area For A Specific Text And Highlights It (In IE The Text Area Scrolls Down Automatically To The Highlighted Text) But In FireFox It Doesn't . . How Can I Make It Scroll Down To The Selected Area My Code Is below :
** Assuming That $()=document.getElementById()
** Also Assuming That The id of the TextArea is "deisng_file_html"
function high_light(search_word){
$('design_file_html').value = $('design_file_html').value.replace(/(\r\n)*/g, "");
$('design_file_html').value = $('design_file_html').value.replace(/(\n)*/g, "");
var sel_start=$('design_file_html').value.indexOf(search_word);
if(sel_start==-1)
{
sel_start=0;
var sel_end=0;
}else{
sel_end=sel_start+search_word.length;
}
if(typeof($('design_file_html').selectionStart)=='number') {
$('design_file_html').focus();
$('design_file_html').select();
$('design_file_html').selectionStart = sel_start;
$('design_file_html').selectionEnd = sel_end;
} else if(document.selection && document.selection.createRange) {
$('design_file_html').focus();
$('design_file_html').select();
var rng2 = document.selection.createRange();
rng2.collapse();
rng2.moveStart('character',$('design_file_html').value.indexOf(search_word));
rng2.moveEnd('character',search_word.length);
rng2.select();
}
}