audiotrack píše:
na to tag neexistuje, je to klasický input type=text a potom musíš vstup spracovať pomocou php a mysql
To neni vôbec pravda možností je viac a tu je jedna z nich.
Toto skopíruj do notepadu a ulož to ako .js
Kód:
/* http://www.kryogenix.org/code/browser/searchhi/ */
/* Modified 20021006 to fix query string parsing and add case insensitivity */
var first = true;
function findPos(obj)
{
var curleft = curtop = 0;
if (obj.offsetParent) {
curleft = obj.offsetLeft
curtop = obj.offsetTop
while (obj = obj.offsetParent) {
curleft += obj.offsetLeft
curtop += obj.offsetTop
}
}
return [curleft,curtop];
}
function highlightWord(node,word) {
// Iterate into this nodes childNodes
if (node.hasChildNodes) {
var hi_cn;
for (hi_cn=0;hi_cn<node.childNodes.length;hi_cn++) {
highlightWord(node.childNodes[hi_cn],word);
}
}
// And do this node itself
if (node.nodeType == 3) { // text node
tempNodeVal = node.nodeValue.toLowerCase();
tempWordVal = word.toLowerCase();
if (tempNodeVal.indexOf(tempWordVal) != -1) {
pn = node.parentNode;
if (pn.className != "searchword") {
// word has not already been highlighted!
nv = node.nodeValue;
ni = tempNodeVal.indexOf(tempWordVal);
// Create a load of replacement nodes
before = document.createTextNode(nv.substr(0,ni));
docWordVal = nv.substr(ni,word.length);
after = document.createTextNode(nv.substr(ni+word.length));
hiwordtext = document.createTextNode(docWordVal);
hiword = document.createElement("span");
hiword.className = "searchword";
hiword.appendChild(hiwordtext);
pn.insertBefore(before,node);
pn.insertBefore(hiword,node);
pn.insertBefore(after,node);
pn.removeChild(node);
if (first) {
document.getElementsByTagName("body")[0].scrollTop = findPos(hiword)[1];
first = false;
}
}
}
}
}
function googleSearchHighlight() {
if (!document.createElement) return;
ref = document.referrer;
if (ref.indexOf('?') == -1) return;
qs = ref.substr(ref.indexOf('?')+1);
qsa = qs.split('&');
for (i=0;i<qsa.length;i++) {
qsip = qsa[i].split('=');
if (qsip.length == 1) continue;
if (qsip[0] == 'q' || qsip[0] == 'p') { // q= for Google, p= for Yahoo
words = unescape(qsip[1].replace(/\+/g,' ')).split(/\s+/);
for (w=0;w<words.length;w++) {
highlightWord(document.getElementsByTagName("body")[0],words[w]);
}
}
}
}
function simpleSearchHighlight() {
first = true;
var slovo = document.getElementById('nick').value;
var words = unescape(slovo).split(/\s+/);
for (w=0;w<words.length;w++) {
if (words[w].length < 4) continue;
highlightWord(document.getElementsByTagName("body")[0],words[w]);
}
return;
}
function cleanWord(node)
{
for (i = node.childNodes.length - 1; i >= 0; i--) {
tn = node.childNodes[i];
// if (tn.nodeType == 3 && tn.className == "searchword") {
if (tn.className == "searchword") {
text = "";
bn = (i > 1) ? node.childNodes[i-1] : null;
an = (i < node.childNodes.length - 2) ? node.childNodes[i+1] : null;
if (bn != null) {
text += bn.nodeValue;
}
text += tn.childNodes[0].nodeValue;
if (an != null) {
text += an.nodeValue;
}
pn = tn.parentNode;
pn.insertBefore(document.createTextNode(text), tn);
if (an != null) pn.removeChild(an);
pn.removeChild(tn);
if (bn != null) pn.removeChild(bn);
}
}
// Iterate into this nodes childNodes
if (node.hasChildNodes) {
var hi_cn;
for (hi_cn=0;hi_cn<node.childNodes.length;hi_cn++) {
cleanWord(node.childNodes[hi_cn]);
}
}
}
function cleanHighlight()
{
cleanWord(document.getElementsByTagName("body")[0]);
}
function cleanAndHighlight()
{
cleanHighlight();
simpleSearchHighlight();
}
function insertPanel()
{
document.getElementsByTagName('html')[0].setAttribute('style','margin-top: 32px;');
var div = document.createElement('div');
div.setAttribute('style', 'position:fixed;top:0;right:0;width:100%;height:31px;padding:0 3px;background-color:#FFFA2F;border-bottom:1px solid #8C8C8C');
var text = document.createElement('input');
text.setAttribute('type', 'text');
text.setAttribute('id','nick');
var button = document.createElement('input');
button.setAttribute('type', 'button');
button.setAttribute('value','Oznacit');
button.setAttribute('onclick', 'cleanAndHighlight();');
document.getElementsByTagName('body')[0].appendChild(div);
div.appendChild(text);
div.appendChild(button);
}
function searchInit()
{
insertPanel();
}
Potom toto skopíruješ do hlavičky(<Head></head>) HTML.
Kód:
<script src="search3.js" type="text/javascript"></script>
<style type="text/css"><!--
span.searchword {
background-color: yellow;
}
--></style>
A potom prepíšeš tag body takto:
Kód:
<body onload="searchInit();">
A hotovo ale táto možnosť nefunguje na IE.
Ak chceš ďalšiu možnosť vyhľadávania tak mi odpíš na môj email.