Autor Zpráva
Šéva
Profil
Zdravím,
našel jsem si script, který umí vyhledávat text v textaree
www.tek-tips.com/faqs.cfm?fid=6479
Ale má to háček, funguje to jen pod IE a já potřebuju, aby to fungovalo pod Firefoxem. Zkoušel jsem to i nějak ohnout, aby to chodilo pod FF,ale bez úspěchu.Vyhledávání přes ctrl+f není v tomto případě, ktery potřebuju dostačující, protože mám ve stránce nekolik iframe a chci vyhledávat pouze v tom jednom iframe, ve kterém zrovna uživatel je.

Díky za rady
pako
Profil *
Šéva:
nie je uplne jasne co vlastne chces dosiahnut. dalo by sa skor povedat ze absolutne nechapem, ale sposob, ktorym to co potrebujes dosiahnut robi IE, robia ostatne prehliadace (pravdepodobne) metodami popisanymi tu:
http://www.w3.org/TR/DOM-Level-2-Traversal-Range/ranges.html - mozes si to skusit ohnut.

pripadne existuje mala kniznica, ktorej metody by ti mohli pomoct http://code.google.com/p/rangyinputs/
na jej prevadzku ale budes potrebovat jQuery
Šéva
Profil
<html>
<head>
    <script type="text/javascript">

        var theRange = null;
        window.onload = function() {
            try {
                theRange = document.getElementById('myText').createTextRange();
            } catch(e) {}

            if (theRange == null) {
                alert('There was an error creating a textRange. Perhaps your browser doesn\'t support them.');
            }
        }

        function findNext() {
            if (theRange != null) {
                theRange.findText(document.getElementById("hledany_vyraz").value);
                theRange.select();
                var charsMoved = theRange.moveStart('character', 3);
                if (charsMoved == 0) {
                    var startAgain = window.confirm('No more matches found. Start again from the beginning?');
                    if (startAgain) {
                        theRange.moveStart('textedit', -1);
                        findNext();
                    }
                }
            }
        }

    </script>
</head>

<body>
    <form>
    Hledaný výraz<br />
    <input type="text" id="hledany_vyraz"><br />
        <textarea id="myText" cols="40" rows="5">Here is some text [ ], and here is some more [ ], and yet even more text! [ ]</textarea>
        <br />
        <input type="button" onclick="findNext();" value="Find next" />
    </form>
</body>
</html>
spusť si tento kód pod IE a potřebuju, aby mi to chodilo i pod Firefoxem...

Vaše odpověď

Mohlo by se hodit

Neumíte-li správně určit příčinu chyby, vkládejte odkazy na živé ukázky.
Užíváte-li nějakou cizí knihovnu, ukažte odpovídajícím, kde jste ji vzali.

Užitečné odkazy:

Prosím používejte diakritiku a interpunkci.

Ochrana proti spamu. Napište prosím číslo dvě-sta čtyřicet-sedm:

0