본문으로 바로가기

index.html


<iframe id="srchform" src="find.html" width="220" height="34" border="0" frameborder="0" scrolling="no"></iframe>


<script>
    var TRange=null;

    function findString (str) {
        if (parseInt(navigator.appVersion)<4) return;
        var strFound;
        if (window.find) {
            // CODE FOR BROWSERS THAT SUPPORT window.find
            strFound=window.find(str);
            if (!strFound) {
                strFound=window.find(str,0,1);
                while (window.find(str,0,1)) continue;

                console.log(strFound);
            }
        } else if (navigator.appName.indexOf("Microsoft")!=-1) {
            // EXPLORER-SPECIFIC CODE
            if (TRange!=null) {
                TRange.collapse(false);
                strFound=TRange.findText(str);
                if (strFound) TRange.select();
            }
            if (TRange==null || strFound==0) {
                TRange=self.document.body.createTextRange();
                strFound=TRange.findText(str);
                if (strFound) TRange.select();
            }
        }else if (navigator.appName=="Opera") {
            alert ("Opera browsers not supported, sorry...")
            return;
        }
        if (!strFound) alert ("String '"+str+"' not found!")
        return;
    }
</script>

 

find.html

<html>
<head>
    <style type="text/css">
        BODY  {
            margin      : 0px;
        }
    </style>
</head>
<body>
<form id="f1" name="f1" action="javascript:void()" onSubmit="if(this.t1.value!=null && this.t1.value!='') parent.findString(this.t1.value);return false;">
    <input type="text" id="t1" name="t1" value="text" size=20>
    <input type="submit" name=b1 value="Find">
</form>
</body>
</html>