A section of JavaScript page search code

Source: Internet
Author: User
Javascript| Page/*
Search text core program, imitation crl+f, but more powerful search
*/
<!--
var Iflag;
function Search () {
var Wpopupelements=wpopup.document.all;
if (wPopupElements.textcase.checked)
{iflag=4;}
Else
{iflag=0;}
if (wpopupelements.searchtext.value==null | | wpopupelements.searchtext.value== ')
{
Wpopup.alert ("Please enter the text you want to find");
Return
}
if (Rng.findtext (Wpopupelements.searchtext.value,10000,iflag) ==true)
{
Rng.select ();
Rng.scrollintoview ();
Rng.movestart ("character");
}
Else
{Wpopup.alert (bottom of document found);}
}

function replace () {
var Wpopupelements=wpopup.document.all;
if (wPopupElements.textcase.checked)
{iflag=4;}
Else
{iflag=0;}
if (wpopupelements.searchtext.value==null | | wpopupelements.searchtext.value== ')
{
Wpopup.alert ("Please enter the text you want to replace");
Return
}
if (Rng.findtext (Wpopupelements.searchtext.value,-10000,iflag) ==true)
{
Rng.text = WPopupElements.replacetext.value;
}
Else
{Wpopup.alert (replaced to bottom of document);}
}

function ReplaceAll () {
var rng = Document.body.createTextRange ();
var Wpopupelements=wpopup.document.all;
if (wPopupElements.textcase.checked)
{iflag=4;}
Else
{iflag=0;}
if (wpopupelements.searchtext.value==null | | wpopupelements.searchtext.value== ')
{
Wpopup.alert ("Please enter the text you want to replace");
Return
}
For (i=0 rng.findtext (Wpopupelements.searchtext.value,10000,iflag)!=false; i++)
{
Rng.scrollintoview ();
Rng.text = WPopupElements.replacetext.value;
}
SetTimeout (' Wpopup.alert ("A total of" +i + "items are replaced") ", 200);
}
-->


/*
Pop-up Search Window Program
*/
<!--
function Gofind () {
Wpopup=window.open (' About:blank ', ', ', ' width=300 height=108 left=350 top=200 menubar=no resizeable=no scrollbars=no Toolbar=no ');
var wpopupdoc=wpopup.document;
Wpopupdoc.open ();
Wpopupdoc.write (' Wpopupdoc.write (' Wpopupdoc.write (' <title> text search function </title>\n ');
Wpopupdoc.write (' <style>\n ');
Wpopupdoc.write (' * {font-size:11px;font-family: "Tahoma", "Verdana", "Arial"}\n);
Wpopupdoc.write (' button {width:80}\n ');
Wpopupdoc.write (' </style>\n ');
Wpopupdoc.write (' Wpopupdoc.write (' <body bgcolor= "buttonface" leftmargin= "0" topmargin= "0" >\n ");
Wpopupdoc.write (' <table width= "height=" 108 "border=" 0 "cellspacing=" 0 "cellpadding=" 3 "bgcolor=" #F1F2DF "> \ n ');
Wpopupdoc.write (' <tr>\n ');
Wpopupdoc.write (' <td> find: </td>\n ');
Wpopupdoc.write (' <td><input type= "text" name= "SearchText" ></td>\n ");
Wpopupdoc.write (' <td><button accesskey= "S" name= "SearchButton" > Find </button></td>\n ');
Wpopupdoc.write (' </tr>\n ');
Wpopupdoc.write (' <tr>\n ');
Wpopupdoc.write (' <td> replacement: </td>\n ');
Wpopupdoc.write (' <td><input type= "text" name= "ReplaceText" ></td>\n ");
Wpopupdoc.write (' <td><button accesskey= "R" name= "ReplaceButton" > Replace </button></td>\n ');
Wpopupdoc.write (' </tr>\n ');
Wpopupdoc.write (' <tr>\n ');
Wpopupdoc.write (' <td colspan= "2" ><input type= "checkbox" Name= "Textcase" value= "textcase" > Case Sensitive &LT;/TD >\n ');
Wpopupdoc.write (' <td><button accesskey= "A" name= "Replaceallbutton" > Replace All </button></td>\n ' );
Wpopupdoc.write (' </tr>\n ');
Wpopupdoc.write (' <tr>\n ');
Wpopupdoc.write (' <td colspan= "2" > </td>\n ');
Wpopupdoc.write (' <td><button accesskey= "C" name= "CancelButton" > Close </button></td>\n ");
Wpopupdoc.write (' </tr>\n ');
Wpopupdoc.write (' </table>\n ');
Wpopupdoc.write (' </body>\n ');
Wpopupdoc.write (' Wpopupdoc.close ();
}
-->


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.