Accueil > > > RECHERCHE D'UN MOT DANS UNE PAGE
RECHERCHE D'UN MOT DANS UNE PAGE
Information sur la source
Description
Voici un petit javascript qui vous permet de rechercher un mot dans une page, en le surlignant (un mot à la fois, recliquer sur le bouton rechercher pour surligner l'instance suivante) Comme vous le voyez, c'est un script qui n'est pas de moi, mais j'ai cependant trouvé utile de le déposer sur ce site.
Source
- <SCRIPT language=JavaScript>
- /* Find In Page Script- By Mike Hall (MHall75819@aol.com) */
- /* Recherche de mot */
- var NS4 = (document.layers); // Which browser?
- var IE4 = (document.all);
- var win = window; // window to search.
- var n = 0;
- function findInPage(str) {
- var txt, i, found;
- if (str == "")
- return false;
- // Find next occurance of the given string on the page, wrap around to the
- // start of the page if necessary.
- if (NS4) {
- // Look for match starting at the current point. If not found, rewind
- // back to the first match.
- if (!win.find(str))
- while(win.find(str, false, true))
- n++;
- else
- n++;
- // If not found in either direction, give message.
- if (n == 0)
- alert("Je suis navré, je n'ai rien trouvé. Vérifiez l'orthographe.");
- }
- if (IE4) {
- txt = win.document.body.createTextRange();
- // Find the nth match from the top of the page.
- for (i = 0; i <= n && (found = txt.findText(str)) != false; i++) {
- txt.moveStart("character", 1);
- txt.moveEnd("textedit");
- }
- // If found, mark it and scroll it into view.
- if (found) {
- txt.moveStart("character", -1);
- txt.findText(str);
- txt.select();
- txt.scrollIntoView();
- n++;
- }
- // Otherwise, start over at the top of the page and find first match.
-
- else {
- if (n > 0) {
- n = 0;
- findInPage(str);
- }
- // Not found anywhere, give message.
- else
- alert("Je suis navré, je n'ai rien trouvé. Vérifiez l'orthographe.");
- }
- }
- return false;
- }
- </SCRIPT>
-
- <FORM name=search onsubmit="return findInPage(this.string.value);"><INPUT
- name=string onchange="n = 0;">
- <INPUT type=submit value=Rechercher></FORM>
<SCRIPT language=JavaScript>
/* Find In Page Script- By Mike Hall (MHall75819@aol.com) */
/* Recherche de mot */
var NS4 = (document.layers); // Which browser?
var IE4 = (document.all);
var win = window; // window to search.
var n = 0;
function findInPage(str) {
var txt, i, found;
if (str == "")
return false;
// Find next occurance of the given string on the page, wrap around to the
// start of the page if necessary.
if (NS4) {
// Look for match starting at the current point. If not found, rewind
// back to the first match.
if (!win.find(str))
while(win.find(str, false, true))
n++;
else
n++;
// If not found in either direction, give message.
if (n == 0)
alert("Je suis navré, je n'ai rien trouvé. Vérifiez l'orthographe.");
}
if (IE4) {
txt = win.document.body.createTextRange();
// Find the nth match from the top of the page.
for (i = 0; i <= n && (found = txt.findText(str)) != false; i++) {
txt.moveStart("character", 1);
txt.moveEnd("textedit");
}
// If found, mark it and scroll it into view.
if (found) {
txt.moveStart("character", -1);
txt.findText(str);
txt.select();
txt.scrollIntoView();
n++;
}
// Otherwise, start over at the top of the page and find first match.
else {
if (n > 0) {
n = 0;
findInPage(str);
}
// Not found anywhere, give message.
else
alert("Je suis navré, je n'ai rien trouvé. Vérifiez l'orthographe.");
}
}
return false;
}
</SCRIPT>
<FORM name=search onsubmit="return findInPage(this.string.value);"><INPUT
name=string onchange="n = 0;">
<INPUT type=submit value=Rechercher></FORM>
Sources de la même categorie
Commentaires et avis
|
Derniers Blogs
COMMENT MAPPER UNE VUE SQL SUR UNE COLLECTION DE COMPLEX TYPE?COMMENT MAPPER UNE VUE SQL SUR UNE COLLECTION DE COMPLEX TYPE? par Matthieu MEZIL
Avec EF, les vues doivent être mappées sur des entity types. Le problème c'est que les entity types doivent avoir une clé. Avec EF, nous avons les complex type qui n'ont pas de clé mais les vues ne peuvent pas être mappées dessus. Avec EF4, il est possibl...
Cliquez pour lire la suite de l'article par Matthieu MEZIL [WF4] UN BINDING ACTIVITY/ACTIVITYDESIGNER QUI PASSE MAL?[WF4] UN BINDING ACTIVITY/ACTIVITYDESIGNER QUI PASSE MAL? par JeremyJeanson
Certain d'entre vous on peut être vécu cette situation embarrassante après quelques temps passer avec WF4 : Au début avec mon " ActivityDesigner" , tout allait bien. Et puis un jour j'ai au des problèmes de " Binding" . Alors nous sommes allé sur le site ...
Cliquez pour lire la suite de l'article par JeremyJeanson MYTIC - SHAREPOINT 2010 : DéJà UN MYTHE MICROSOFT ?MYTIC - SHAREPOINT 2010 : DéJà UN MYTHE MICROSOFT ? par junarnoalg
La prochaine session de MyTIC aura lieu à Namur, le 23 mars prochain. Pendant presque une heure, nous parlerons de SharePoint 2010. Voici un aperçu du programme.
Accueil : 17h30 Début de la session : 18h00 - Les nouvelles int...
Cliquez pour lire la suite de l'article par junarnoalg
Logiciels
Academy System (10.9.4.0)ACADEMY SYSTEM (10.9.4.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System Xilisoft Convertisseur Vidéo Ultimate (5.1.39.0305)XILISOFT CONVERTISSEUR VIDéO ULTIMATE (5.1.39.0305)Xilisoft Convertisseur Vidéo Ultimate est un outil puissant de conversion vidéo, facile à utilise... Cliquez pour télécharger Xilisoft Convertisseur Vidéo Ultimate Xilisoft DVD Ripper Ultimate (5.0.64.0304)XILISOFT DVD RIPPER ULTIMATE (5.0.64.0304)Xilisoft DVD Ripper Ultimate est un logiciel excellent pour copier et convertir DVD vers presque ... Cliquez pour télécharger Xilisoft DVD Ripper Ultimate Rigs of Rods (63.3)RIGS OF RODS (63.3)c'est un jeu de multi-simulation camions,autobus voitures, avions, bateaux, hélicoptère avec défo... Cliquez pour télécharger Rigs of Rods
|