Crime_Killer
Neues Mitglied
gibbet einen code für eine html suchfunktion auf einer website
z.B. wenn jemand auf meiner seite ein wort suchen möchte ???
:?:
z.B. wenn jemand auf meiner seite ein wort suchen möchte ???
:?:
Follow along with the video below to see how to install our site as a web app on your home screen.
Anmerkung: This feature may not be available in some browsers.
/*
Find In Page Script- By Mike Hall ([email protected])
Permission granted to Dynamicdrive.com to feature script in archive
For full source code, visit http://dynamicdrive.com
*/
var NS4 = (document.layers);
var IE4 = (document.all);
var win = window;
var n = 0;
function findInPage(str) {
var txt, i, found;
if (str == "")
return false;
if (NS4) {
if (!win.find(str))
while(win.find(str, false, true))
n++;
else
n++;
if (n == 0)
alert("Nicht gefunden.");
}
if (IE4) {
txt = win.document.body.createTextRange();
for (i = 0; i <= n && (found = txt.findText(str)) != false; i++) {
txt.moveStart("character", 1);
txt.moveEnd("textedit");
}
if (found) {
txt.moveStart("character", -1);
txt.findText(str);
txt.select();
txt.scrollIntoView();
n++;
}
else {
if (n > 0) {
n = 0;
findInPage(str);
}
else
alert("Nicht gefunden.");
}
}
return false;
}
<html>
<head>
<title>suchscript</title>
<script language="JavaScript" src="find.js"></script>
</head>
<body onload="init()">
<form name="search" onSubmit="return findInPage(this.string.value);">
<input name="string" type="text" size="32" onChange="n = 0;">
<input type="reset" VALUE="Reset">
<input type="submit" value="Suche auf dieser Seite">
</form>
</body>
</html>