Path: csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Dr J R Stockton Newsgroups: comp.lang.javascript Subject: Re: Searching the visual appearance of a Web page? Date: Thu, 3 Mar 2016 23:25:42 +0000 Organization: Home Lines: 61 Message-ID: <78AX6LG2fM2WFw29@invalid.uk.co.demon.merlyn.invalid> References: Mime-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit Injection-Info: mx02.eternal-september.org; posting-host="01da9e6251d9b3ee47bb70bebae42d53"; logging-data="15654"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+fks5ThPhSZucFWAHqMn8CQrcV8UdfLqk=" User-Agent: Turnpike/6.05-S () Cancel-Lock: sha1:5hf8NajW39yt2/WOWL0pppCdIMo= Xref: csiph.com comp.lang.javascript:29790 In comp.lang.javascript message , Tue, 1 Mar 2016 11:39:17, Martin Honnen posted: >Dr J R Stockton wrote: >> I have a reference to the body element of a local Web page, and can >> assume that body.onload() has finished. I also have a RegExp, which has >> been defined from the value of an input type=text element. >> >> I want to apply that RegExp to the whole displayed text, all at once or >> piecemeal, and get all of the matches. I have been using the match >> method on body.innerText, body.innerHTML, or body.textContent, which was >> good enough to do what I wanted, but not ideal. >> >> For example, the text up
on in the HTML source must be treated as the >> two words "up on" and not the one word "upon". And, if practical, >> "câm" should be treated as a three-letter word. > >innerText should give you a plain string in which e.g.
has been >converted to a new line character and a character reference to its >character. The only drawback is that Firefox in its current version 44 >does not support it, but according to http://perfectionkills.com/the- >poor-misunderstood-innerText/ in Firefox 45 we will see support. So >doing the regular expression search on body.innerText seems like the >most promising approach. Or why did "innerText" not give you the ideal >result, unless you needed it with Mozilla browsers? I habitually use the most recent ordinary release of Firefox - Firefox has "Zoom Text Only" which I consider essential. I'm using WinXP sp3, and reading files into an iframe, directly from the disc without any server, WinXP sp3. Early Chrome was OK, but Chrome 4.0 & later does not do that, it misapplies "Same domain Policy". Something fails in Opera 35, with a decent error message; but Opera 12.18 is OK. IE8 is OK. Vivaldi gives a message like Opera 35, then falls over dead. I get the content of the page variously with textContent, innerText, and innerHTML - and should review those after Firefox 45 appears. So, as Firefox 45 is due out on Tuesday ... One use is to search for candidate acronyms for listing across a web site master - upper-case words of sensible length. I should be able to arrange to maintain a list of acronyms already known (e.g. NATO) and non-acronyms that look like that (e.g. KABOOM), and then report only the ones not listed there ... For amusement - a few years ago, Firefox and Opera would not load page X.HTM into an IFRAME in page X.HTM, but others would. The workround, to read itself rather than a copy of itself, is still in place, and I wonder whether it is now needed in none, some, or any of the current browsers. Thanks. > ... -- (c) John Stockton, Surrey, UK. ¬@merlyn.demon.co.uk Turnpike v6.05 MIME. Merlyn Web Site < > - FAQish topics, acronyms, & links.