Home > Web Front-end > JS Tutorial > body text

一个用js实现的页内搜索代码_javascript技巧

WBOY
Release: 2016-05-16 19:12:59
Original
1128 people have browsed it
  
  
  
<script> <BR>var NS4 = (document.layers); <BR>var IE4 = (document.all); <BR>var win = window; <BR>var n = 0; <BR>function findInPage(str) { <BR>var txt, i, found; <BR>if (str == "") <BR>return false; <BR>if (NS4) { <BR>if (!win.find(str)) <BR>while(win.find(str, false, true)) <BR>n++; <BR>else <BR>n++; <BR>if (n == 0) <BR>alert("Not found."); <BR>} <br><br>if (IE4) { <BR>txt = win.document.body.createTextRange(); <BR>for (i = 0; i <= n && (found = txt.findText(str)) != false; i++) { <BR>txt.moveStart("character", 1); <BR>txt.moveEnd("textedit"); <BR>} <BR>if (found) { <BR>txt.moveStart("character", -1); <BR>txt.findText(str); <BR>txt.select(); <BR>txt.scrollIntoView(); <BR>n++; <BR>} <BR>else { <BR>if (n > 0) { <BR>n = 0; <BR>findInPage(str); <BR>} <BR>else <BR>alert(" 不好意思,在本页没找到,是不是到其它类别去看看呢?\n 如果还没有找到,请给我发邮件(fred_fan@163.net)吧,我会尽力找找…… \n云孩儿 http://www.yunboys.com"); <BR>} <BR>} <br><br>return false; <BR>} <br><br></script> 

中国日报网环球在线消息:英国首相布莱尔5月10日在英格兰北部塞奇菲尔德选区的特里姆登工党活动中心(Trimdon Labour Club)宣布,他已经决定辞去工党领袖职务,并将于6月27日辞去英国首相职务,按照英国法律,工党通过选举产生新的党领袖后,其新领袖将接替布莱尔担任内阁首相,直至2010年5月本届首相任期期满。 

  据英国媒体报道,现在布莱尔内阁中的财政大臣戈登·布朗被认为是工党新领袖和英国新首相的最热门人选。布莱尔5月1日曾表示,布朗将成为一个出色的首相。 

 
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!