1
工作,我使用從腳本:http://www.javascripter.net/faq/searchin.htm 但這不是InternetExplorer的11搜索文本腳本不IE11
工作了任何想法,以解決這一問題?並使其適用於所有瀏覽器?
var TRange=null
function findString (str, win) {
if (parseInt(navigator.appVersion)<4) return;
var strFound;
if (navigator.appName=="Netscape") {
if (!win) win = self;
win.focus();
// NAVIGATOR-SPECIFIC CODE
strFound=win.find(str);
if (!strFound) {
strFound=win.find(str,0,1)
while (win.find(str,0,1)) continue
}
}
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=win.document.body.createTextRange()
strFound=TRange.findText(str)
if (strFound) TRange.select()
}
}
if (!strFound) alert ("Helaas '"+str+"' werd niet gevonden! Probeer iets anders...")
}
我的IE 11的謊言和說,這是網景,所以我改變'== 「Netscape的」'來使用特徵檢測如'&& typeof(win?win:self).find!='undefined'' –