Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #38633 > unrolled thread

How get windows FIND() to work?

Started byRobert Baer <robertbaer@localnet.com>
First post2020-08-03 19:13 -0700
Last post2020-08-06 12:40 -0700
Articles 20 on this page of 42 — 8 participants

Back to article view | Back to comp.lang.javascript


Contents

  How get windows FIND() to work? Robert Baer <robertbaer@localnet.com> - 2020-08-03 19:13 -0700
    Re: How get windows FIND() to work? Arno Welzel <usenet@arnowelzel.de> - 2020-08-04 04:49 +0200
      Re: How get windows FIND() to work? Julio Di Egidio <julio@diegidio.name> - 2020-08-04 02:11 -0700
        Re: How get windows FIND() to work? Arno Welzel <usenet@arnowelzel.de> - 2020-08-04 12:02 +0200
      Re: How get windows FIND() to work? Robert Baer <robertbaer@localnet.com> - 2020-08-04 20:06 -0700
        Re: How get windows FIND() to work? Arno Welzel <usenet@arnowelzel.de> - 2020-08-05 07:55 +0200
    Re: How get windows FIND() to work? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2020-08-03 19:55 -0700
      Re: How get windows FIND() to work? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2020-08-05 08:35 +0200
        Re: How get windows FIND() to work? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2020-08-05 11:19 -0700
          Highlighting text (was: How get windows FIND() to work?) Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2020-08-06 02:15 +0200
    Re: How get windows FIND() to work? Clifford Heath <no.spam@please.net> - 2020-08-04 15:22 +1000
      Re: How get windows FIND() to work? Robert Baer <robertbaer@localnet.com> - 2020-08-04 10:06 -0700
        Re: How get windows FIND() to work? Arno Welzel <usenet@arnowelzel.de> - 2020-08-04 19:42 +0200
      Re: How get windows FIND() to work? Robert Baer <robertbaer@localnet.com> - 2020-08-04 20:13 -0700
        Re: How get windows FIND() to work? Clifford Heath <no.spam@please.net> - 2020-08-05 19:56 +1000
          Re: How get windows FIND() to work? Arno Welzel <usenet@arnowelzel.de> - 2020-08-05 13:54 +0200
            Re: How get windows FIND() to work? Clifford Heath <no.spam@please.net> - 2020-08-05 21:55 +1000
              Re: How get windows FIND() to work? Arno Welzel <usenet@arnowelzel.de> - 2020-08-05 15:40 +0200
                Re: How get windows FIND() to work? Robert Baer <robertbaer@localnet.com> - 2020-08-06 12:27 -0700
                  Re: How get windows FIND() to work? Arno Welzel <usenet@arnowelzel.de> - 2020-08-07 14:09 +0200
              Re: How get windows FIND() to work? Robert Baer <robertbaer@localnet.com> - 2020-08-06 12:24 -0700
            Re: How get windows FIND() to work? Robert Baer <robertbaer@localnet.com> - 2020-08-06 12:23 -0700
          Re: How get windows FIND() to work? Robert Baer <robertbaer@localnet.com> - 2020-08-06 12:16 -0700
    Re: How get windows FIND() to work? "R.Wieser" <address@not.available> - 2020-08-04 09:10 +0200
      Re: How get windows FIND() to work? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2020-08-04 23:46 +0200
        Re: How get windows FIND() to work? Robert Baer <robertbaer@localnet.com> - 2020-08-04 20:21 -0700
          Re: How get windows FIND() to work? Arno Welzel <usenet@arnowelzel.de> - 2020-08-05 07:56 +0200
            Re: How get windows FIND() to work? Robert Baer <robertbaer@localnet.com> - 2020-08-06 11:40 -0700
              Re: How get windows FIND() to work? Arno Welzel <usenet@arnowelzel.de> - 2020-08-07 14:26 +0200
        Re: How get windows FIND() to work? "R.Wieser" <address@not.available> - 2020-08-05 08:59 +0200
          Re: How get windows FIND() to work? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2020-08-06 01:11 +0200
        Re: How get windows FIND() to work? Clifford Heath <no.spam@please.net> - 2020-08-06 11:36 +1000
          Re: How get windows FIND() to work? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2020-08-06 12:24 +0200
            Re: How get windows FIND() to work? Robert Baer <robertbaer@localnet.com> - 2020-08-06 12:40 -0700
              Re: How get windows FIND() to work? "R.Wieser" <address@not.available> - 2020-08-07 10:27 +0200
              Re: How get windows FIND() to work? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2020-08-08 04:39 +0200
            Re: How get windows FIND() to work? Clifford Heath <no.spam@please.net> - 2020-08-07 18:46 +1000
    Highlighting text (was: How get windows FIND() to work?) Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2020-08-05 08:32 +0200
      Re: Highlighting text (was: How get windows FIND() to work?) "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2020-08-05 21:59 -0700
        Re: Highlighting text (was: How get windows FIND() to work?) Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2020-08-08 04:22 +0200
      Re: Highlighting text Robert Baer <robertbaer@localnet.com> - 2020-08-06 12:06 -0700
    Re: How get windows FIND() to work? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2020-08-06 12:40 -0700

Page 2 of 3 — ← Prev page 1 [2] 3  Next page →


#38688

FromRobert Baer <robertbaer@localnet.com>
Date2020-08-06 12:24 -0700
Message-ID<uNYWG.107334$TO4.28125@fx05.iad>
In reply to#38672
Clifford Heath wrote:
> On 5/8/20 9:54 pm, Arno Welzel wrote:
>> Clifford Heath:
>>
>>> On 5/8/20 1:13 pm, Robert Baer wrote:
>> [...]
>>>>     Better to get the browser to do its thing; even IE8 does a nice
>>>> brwser FIND().
>>>
>>> I know of no standard way that find-in-page behaviour can be automated.
>>
>> That was already mentioned:
>> <https://developer.mozilla.org/en-US/docs/Web/API/Window/find>
> 
> What part of "no standard way" is difficult to understand?
   Talk to "moz".

[toc] | [prev] | [next] | [standalone]


#38687

FromRobert Baer <robertbaer@localnet.com>
Date2020-08-06 12:23 -0700
Message-ID<DMYWG.107333$TO4.102461@fx05.iad>
In reply to#38671
Arno Welzel wrote:
> Clifford Heath:
> 
>> On 5/8/20 1:13 pm, Robert Baer wrote:
> [...]
>>>     Better to get the browser to do its thing; even IE8 does a nice
>>> brwser FIND().
>>
>> I know of no standard way that find-in-page behaviour can be automated.
> 
> That was already mentioned:
> <https://developer.mozilla.org/en-US/docs/Web/API/Window/find>
> 
> 
...and....i also mentioned to add all that in every document for 
thousands of keywords into a goodly batch of documents is not exactly sane.

   Thanks

[toc] | [prev] | [next] | [standalone]


#38686

FromRobert Baer <robertbaer@localnet.com>
Date2020-08-06 12:16 -0700
Message-ID<ZFYWG.171924$%p.18563@fx33.iad>
In reply to#38670
Clifford Heath wrote:
> On 5/8/20 1:13 pm, Robert Baer wrote:
>> Clifford Heath wrote:
>>> On 4/8/20 12:13 pm, Robert Baer wrote:
>>>>    Environment: Win7.1 Firefox 78
>>>>
>>>>     Sample line used:
>>>> <a href="downhole-measurements.html?find=able">Downhole 
>>>> Measurements</a>
>>>>
>>>>     At least execution transfers from the calling HTML to the 
>>>> desired destination HTML.
>>>>
>>>>     BUT. the keyword does NOT get underlined or highlighted in any way.
>>>>     It would be particularly nice if all the keywords got 
>>>> highlighted and the first keyword was presented on the screen (think 
>>>> loong document and keyword was in middle).
>>>
>>> You won't get highlighting without adding Javascript.
>>>
>>> I suggest you use a fragment identifier:
>>>
>>> <a href="downhole-measurements.html#able">Downhole Measurements</a>
>>>
>>> because that gets passed to the browser, which will scroll to the 
>>> matching <a name="able"> tag. The fragment string is also available 
>>> to Javascript by using
>>>
>>> var fragment = location.hash; // Returns '#able'
>>>
>>> You could use that to highlight the appropriate text.
>>>
>>> Clifford Heath.
>>    You mean "without adding Javascript" refers to the document.
>>    Adding matching <a name="able"> tags all over the document is not 
>> sane; there are thousands of words needed to be found/highlighted.
>>
>>    Better to get the browser to do its thing; even IE8 does a nice 
>> brwser FIND().
> 
> I know of no standard way that find-in-page behaviour can be automated.
> 
> CH
> 
   Other than "forcing" a browser to doa nominally manual search, that 
seems to be true.

   However, the grand expert Thomas 'PointedEars' Lahn may have given us 
highlight.js as an answer

     Thanks

[toc] | [prev] | [next] | [standalone]


#38640

From"R.Wieser" <address@not.available>
Date2020-08-04 09:10 +0200
Message-ID<rgb1m6$18k6$1@gioia.aioe.org>
In reply to#38633
Robert,

>    Sample line used:
> < a href="downhole-measurements.html?find=able">Downhole Measurements< /a>

I think you are looking for

< a href="downhole-measurements.html#able">Downhole Measurements< /a>

with in that "downhole-measurements.html" document the following line just
above the "able" chapter

< a name="able">

(remove the spaces after the "<" symbols)

Regards,
Rudy Wieser


[toc] | [prev] | [next] | [standalone]


#38651

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2020-08-04 23:46 +0200
Message-ID<XnsAC0FF1EBE7D62eejj99@194.109.6.166>
In reply to#38640
"R.Wieser" <address@not.available> wrote on 04 Aug 2020 in 
comp.lang.javascript:

> Robert,
> 
>>    Sample line used:
>> < a href="downhole-measurements.html?find=able">Downhole Measurements
< /a>
> 
> I think you are looking for
> 
> < a href="downhole-measurements.html#able">Downhole Measurements< /a>
> 
> with in that "downhole-measurements.html" document the following line just
> above the "able" chapter
> 
> < a name="able">
> 
> (remove the spaces after the "<" symbols)
> 
> Regards,
> Rudy Wieser

Google Chrome 84 and up, desktop and mobile,
let you highlight "This text" from the url-string:

https://example.org/page.html#:~:text=This%20text




-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

[toc] | [prev] | [next] | [standalone]


#38656

FromRobert Baer <robertbaer@localnet.com>
Date2020-08-04 20:21 -0700
Message-ID<1BpWG.140475$7vd.62888@fx35.iad>
In reply to#38651
Evertjan. wrote:
> "R.Wieser" <address@not.available> wrote on 04 Aug 2020 in
> comp.lang.javascript:
> 
>> Robert,
>>
>>>     Sample line used:
>>> < a href="downhole-measurements.html?find=able">Downhole Measurements
> < /a>
>>
>> I think you are looking for
>>
>> < a href="downhole-measurements.html#able">Downhole Measurements< /a>
>>
>> with in that "downhole-measurements.html" document the following line just
>> above the "able" chapter
>>
>> < a name="able">
>>
>> (remove the spaces after the "<" symbols)
>>
>> Regards,
>> Rudy Wieser
> 
> Google Chrome 84 and up, desktop and mobile,
> let you highlight "This text" from the url-string:
> 
> https://example.org/page.html#:~:text=This%20text
> 
> 
> 
> 
    Even IE8 FIND() works; highlights all found keywords dynamically, 
allows previous/next.
    Seems most browsers support this rather well.

    Thanks

[toc] | [prev] | [next] | [standalone]


#38659

FromArno Welzel <usenet@arnowelzel.de>
Date2020-08-05 07:56 +0200
Message-ID<hov01bFtpm8U2@mid.individual.net>
In reply to#38656
Robert Baer:

[...]
>     Even IE8 FIND() works; highlights all found keywords dynamically, 
> allows previous/next.
>     Seems most browsers support this rather well.

So - why did you even ask in the first place when you already know the
solution?


-- 
Arno Welzel
https://arnowelzel.de

[toc] | [prev] | [next] | [standalone]


#38684

FromRobert Baer <robertbaer@localnet.com>
Date2020-08-06 11:40 -0700
Message-ID<E8YWG.289677$DO2.76233@fx45.iad>
In reply to#38659
Arno Welzel wrote:
> Robert Baer:
> 
> [...]
>>      Even IE8 FIND() works; highlights all found keywords dynamically,
>> allows previous/next.
>>      Seems most browsers support this rather well.
> 
> So - why did you even ask in the first place when you already know the
> solution?
> 
> 
   I do NOT know the solution; requiring the user to enter 
<Ctrl>f<desiredkeyword> is not a sane requirement,

   Thanks

[toc] | [prev] | [next] | [standalone]


#38696

FromArno Welzel <usenet@arnowelzel.de>
Date2020-08-07 14:26 +0200
Message-ID<hp4vjpF2lt6U1@mid.individual.net>
In reply to#38684
Robert Baer:

> Arno Welzel wrote:
>> Robert Baer:
>>
>> [...]
>>>      Even IE8 FIND() works; highlights all found keywords dynamically,
>>> allows previous/next.
>>>      Seems most browsers support this rather well.
>>
>> So - why did you even ask in the first place when you already know the
>> solution?
>>
>>
>    I do NOT know the solution; requiring the user to enter 
> <Ctrl>f<desiredkeyword> is not a sane requirement,

Huh?

<https://arnowelzel.de/samples/find.html>

And to search for something there:

<https://arnowelzel.de/samples/find.html?find=voluptua>

This is just a rough "quick & dirty" example and uses window.find() and
URLSearchParams(). This is NOT standard and may NOT work with every
browser. It works for me with Firefox 79.0 and should also work with
most Chrome based browsers.

However - I would *not* recommend this for production. And for
highlighting *every* found word, adding next/prev etc. you need to
create your own script.



-- 
Arno Welzel
https://arnowelzel.de

[toc] | [prev] | [next] | [standalone]


#38663

From"R.Wieser" <address@not.available>
Date2020-08-05 08:59 +0200
Message-ID<rgdlds$mf7$1@gioia.aioe.org>
In reply to#38651
Evertjan,

> Google Chrome 84 and up, desktop and mobile,
> let you highlight "This text" from the url-string:
>
> https://example.org/page.html#:~:text=This%20text

Thats the first time I've ever heard of it.  Thanks.

Regards,
Rudy Wieser

[toc] | [prev] | [next] | [standalone]


#38675

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2020-08-06 01:11 +0200
Message-ID<XnsAC11C1D3833Ceejj99@194.109.6.166>
In reply to#38663
"R.Wieser" <address@not.available> wrote on 05 Aug 2020 in 
comp.lang.javascript:

> Evertjan,
> 
>> Google Chrome 84 and up, desktop and mobile,
>> let you highlight "This text" from the url-string:
>>
>> https://example.org/page.html#:~:text=This%20text
> 
> Thats the first time I've ever heard of it.  Thanks.

There has to be a first time for everything. Haha.

-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

[toc] | [prev] | [next] | [standalone]


#38677

FromClifford Heath <no.spam@please.net>
Date2020-08-06 11:36 +1000
Message-ID<m8JWG.75479$355.6557@fx27.iad>
In reply to#38651
On 5/8/20 7:46 am, Evertjan. wrote:
> "R.Wieser" <address@not.available> wrote on 04 Aug 2020 in
> comp.lang.javascript:
> 
>> Robert,
>>
>>>     Sample line used:
>>> < a href="downhole-measurements.html?find=able">Downhole Measurements
> < /a>
>>
>> I think you are looking for
>>
>> < a href="downhole-measurements.html#able">Downhole Measurements< /a>
>>
>> with in that "downhole-measurements.html" document the following line just
>> above the "able" chapter
>>
>> < a name="able">
>>
>> (remove the spaces after the "<" symbols)
>>
>> Regards,
>> Rudy Wieser
> 
> Google Chrome 84 and up, desktop and mobile,
> let you highlight "This text" from the url-string:
> 
> https://example.org/page.html#:~:text=This%20text

Not Chrome "Version 84.0.4147.89 (Official Build) (64-bit)" for OS/X.

Where is this feature documented, please?

CH

[toc] | [prev] | [next] | [standalone]


#38679

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2020-08-06 12:24 +0200
Message-ID<XnsAC117E3999C56eejj99@194.109.6.166>
In reply to#38677
Clifford Heath <no.spam@please.net> wrote on 06 Aug 2020 in
comp.lang.javascript: 

> On 5/8/20 7:46 am, Evertjan. wrote:
>> "R.Wieser" <address@not.available> wrote on 04 Aug 2020 in
>> comp.lang.javascript:
>> 
>>> Robert,
>>>
>>>>     Sample line used:
>>>> < a href="downhole-measurements.html?find=able">Downhole Measurements
>> < /a>
>>>
>>> I think you are looking for
>>>
>>> < a href="downhole-measurements.html#able">Downhole Measurements< /a>
>>>
>>> with in that "downhole-measurements.html" document the following line
>>> just above the "able" chapter
>>>
>>> < a name="able">
>>>
>>> (remove the spaces after the "<" symbols)
>>>
>>> Regards,
>>> Rudy Wieser
>> 
>> Google Chrome 84 and up, desktop and mobile,
>> let you highlight "This text" from the url-string:
>> 
>> https://example.org/page.html#:~:text=This%20text
> 
> Not Chrome "Version 84.0.4147.89 (Official Build) (64-bit)" for OS/X.

<https://www.henk-weltje.nl/index.php/oude-boekwerkjes/watermolens-in-
apeldoorn#:~:text=Tijdens%20het%20nadenken%20over%20een%20geschikt%
20onderwerp>

In Version 84.0.4147.105 (Official Build) (64-bit), it does,

as does my Chrome Mobile for Android .111 32b

================

You can even make a bookmark with:

javascript:(function()%7Bconst selectedText %3D getSelection().toString()%
3Bconst newUrl %3D new URL(location)%3BnewUrl.hash %3D %60%3A~%3Atext%3D%24%
7BencodeURIComponent(selectedText)%7D%60%3Bwindow.open(newUrl)%7D)()

.. witch will make this url-string for you, 
after highlighting the wanted text by mouse.


> Where is this feature documented, please?

Read it somewhere in the Dev-blog, I suppose,
or css-tricks perhaps.

-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

[toc] | [prev] | [next] | [standalone]


#38690

FromRobert Baer <robertbaer@localnet.com>
Date2020-08-06 12:40 -0700
Message-ID<J0ZWG.289678$DO2.226369@fx45.iad>
In reply to#38679
Evertjan. wrote:
> Clifford Heath <no.spam@please.net> wrote on 06 Aug 2020 in
> comp.lang.javascript:
> 
>> On 5/8/20 7:46 am, Evertjan. wrote:
>>> "R.Wieser" <address@not.available> wrote on 04 Aug 2020 in
>>> comp.lang.javascript:
>>>
>>>> Robert,
>>>>
>>>>>      Sample line used:
>>>>> < a href="downhole-measurements.html?find=able">Downhole Measurements
>>> < /a>
>>>>
>>>> I think you are looking for
>>>>
>>>> < a href="downhole-measurements.html#able">Downhole Measurements< /a>
>>>>
>>>> with in that "downhole-measurements.html" document the following line
>>>> just above the "able" chapter
>>>>
>>>> < a name="able">
>>>>
>>>> (remove the spaces after the "<" symbols)
>>>>
>>>> Regards,
>>>> Rudy Wieser
>>>
>>> Google Chrome 84 and up, desktop and mobile,
>>> let you highlight "This text" from the url-string:
>>>
>>> https://example.org/page.html#:~:text=This%20text
>>
>> Not Chrome "Version 84.0.4147.89 (Official Build) (64-bit)" for OS/X.
> 
> <https://www.henk-weltje.nl/index.php/oude-boekwerkjes/watermolens-in-
> apeldoorn#:~:text=Tijdens%20het%20nadenken%20over%20een%20geschikt%
> 20onderwerp>
> 
> In Version 84.0.4147.105 (Official Build) (64-bit), it does,
> 
> as does my Chrome Mobile for Android .111 32b
> 
> ================
> 
> You can even make a bookmark with:
> 
> javascript:(function()%7Bconst selectedText %3D getSelection().toString()%
> 3Bconst newUrl %3D new URL(location)%3BnewUrl.hash %3D %60%3A~%3Atext%3D%24%
> 7BencodeURIComponent(selectedText)%7D%60%3Bwindow.open(newUrl)%7D)()
> 
> .. witch will make this url-string for you,
> after highlighting the wanted text by mouse.
* How could someone be so stupid as to 1) search a document for a 
keyword first, then 2) construct a complex URL to FIND that keyword?

> 
> 
>> Where is this feature documented, please?
> 
> Read it somewhere in the Dev-blog, I suppose,
> or css-tricks perhaps.
> 

[toc] | [prev] | [next] | [standalone]


#38692

From"R.Wieser" <address@not.available>
Date2020-08-07 10:27 +0200
Message-ID<rgj3a8$1pvo$1@gioia.aioe.org>
In reply to#38690
Robert,

> * How could someone be so stupid as to 1) search a document for a keyword 
> first, then 2) construct a complex URL to FIND that keyword?

To help someone even more "stupid" ?

Being able to send a friend/granny/client an URL which causes the webpage 
scroll to and hilite the phrase/line you want them to read an talk about 
could be quite handy.  Not everyone knows (or wants to know!) how to use 
their webbrowser beyond clicking a link and scroll thru the result.

Heck, I could even emagine it being handy for myself as a way to "bookmark" 
stuff on certain webpages, even on pages I've stored locally.

Also, what makes you think that whomever wants to use such an URL needs to 
construct it himself ?    I could imagine a local page containing some JS 
could do it.  Also, plugins, other kinds of scripting (VBScript) and 
programs.  Just drop the URL and sought-for text into two input fields, 
press the button and copy the result.

Regards,
Rudy Wieser

[toc] | [prev] | [next] | [standalone]


#38699

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2020-08-08 04:39 +0200
Message-ID<2553188.mvXUDI8C0e@PointedEars.de>
In reply to#38690
Robert Baer amok-crossposted to alt.computer, comp.lang.javascript, and 
sci.electronics.design

> Evertjan. wrote:
>> You can even make a bookmark with:
>> 
>> javascript:(function()%7Bconst selectedText %3D
>> getSelection().toString()% 3Bconst newUrl %3D new
>> URL(location)%3BnewUrl.hash %3D %60%3A~%3Atext%3D%24%
>> 7BencodeURIComponent(selectedText)%7D%60%3Bwindow.open(newUrl)%7D)()

The source code of this can be obtained with decodeURIComponent().
Formatted:

(function () {
  const selectedText = getSelection().toString();
  const newUrl = new URL(location);
  newUrl.hash = `:~:text=${encodeURIComponent(selectedText)}`;
  window.open(newUrl);
})();

BTW, this is an instance where using template strings is unnecessary:

  newUrl.hash = ':~:text=' + encodeURIComponent(selectedText);

suffices and is probably even more efficient.

>> .. witch will make this url-string for you,
      ^^^^^
_which_

>> after highlighting the wanted text by mouse.
> * How could someone be so stupid as to 1) search a document for a
> keyword first, then 2) construct a complex URL to FIND that keyword?

For sharing the highlighted variant of a Web site.  There had been an add-
on/extension to do the same, but IIRC it became incompatible with newer 
versions.

I have been thinking about doing something similar for a while, and now
I have gotten a good idea how to do it :)

F’up2 comp.lang.javascript

-- 
PointedEars
FAQ: <http://PointedEars.de/faq> | <http://PointedEars.de/es-matrix>
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.

[toc] | [prev] | [next] | [standalone]


#38693

FromClifford Heath <no.spam@please.net>
Date2020-08-07 18:46 +1000
Message-ID<3y8XG.111647$Vp4.22850@fx44.iad>
In reply to#38679
On 6/8/20 8:24 pm, Evertjan. wrote:
> Clifford Heath <no.spam@please.net> wrote on 06 Aug 2020 in
> comp.lang.javascript:
> 
>> On 5/8/20 7:46 am, Evertjan. wrote:
>>> "R.Wieser" <address@not.available> wrote on 04 Aug 2020 in
>>> comp.lang.javascript:
>>>
>>>> Robert,
>>>>
>>>>>      Sample line used:
>>>>> < a href="downhole-measurements.html?find=able">Downhole Measurements
>>> < /a>
>>>>
>>>> I think you are looking for
>>>>
>>>> < a href="downhole-measurements.html#able">Downhole Measurements< /a>
>>>>
>>>> with in that "downhole-measurements.html" document the following line
>>>> just above the "able" chapter
>>>>
>>>> < a name="able">
>>>>
>>>> (remove the spaces after the "<" symbols)
>>>>
>>>> Regards,
>>>> Rudy Wieser
>>>
>>> Google Chrome 84 and up, desktop and mobile,
>>> let you highlight "This text" from the url-string:
>>>
>>> https://example.org/page.html#:~:text=This%20text
>>
>> Not Chrome "Version 84.0.4147.89 (Official Build) (64-bit)" for OS/X.
> 
> <https://www.henk-weltje.nl/index.php/oude-boekwerkjes/watermolens-in-
> apeldoorn#:~:text=Tijdens%20het%20nadenken%20over%20een%20geschikt%
> 20onderwerp>
> 
> In Version 84.0.4147.105 (Official Build) (64-bit), it does,

Interestingly, it works for me now - I must have made an error yesterday.

Thanks.

CH

[toc] | [prev] | [next] | [standalone]


#38660 — Highlighting text (was: How get windows FIND() to work?)

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2020-08-05 08:32 +0200
SubjectHighlighting text (was: How get windows FIND() to work?)
Message-ID<3317374.iIbC2pHGDl@PointedEars.de>
In reply to#38633
[Stop amok-crossposting.  This has nothing to do with computers in general 
or electronics design.  *facepalm*]

Robert Baer wrote:

>    Environment: Win7.1 Firefox 78
> 
>     Sample line used:
> <a href="downhole-measurements.html?find=able">Downhole Measurements</a>

What is happening then depends on the user agent.  It is NOT a general 
command to highlight something.  HTML is NOT a programming language.

The FIND command of CMD.exe has *nothing to do* with HTML/JavaScript.  
JavaScript is *case-sensitive*.  And “window” is NOT “windows”.
 
>     At least execution transfers from the calling HTML to the desired
> destination HTML.

HTML is _NOT_ a programming language.  HTML does NOT “execute” and does NOT 
“call”.
 
>     BUT. the keyword does NOT get underlined or highlighted in any way.

Of course not.  HTML – HyperText *Markup* Language – is _NOT_ a programming 
language.  To highlight something *in general*, you need a *programming* 
language.

>     It would be particularly nice if all the keywords got highlighted
> and the first keyword was presented on the screen (think loong document
> and keyword was in middle).
> 
>    Help?

-- downhole-measurements.html -----------------------------------

<!DOCTYPE html>
<html>
  <head>
    <!-- … -->
    <script src='highlight.js'></script>
    <!-- … -->
  </head>

  <body onload='highlight.highlightAndFocus()'>
    <!-- … -->
  </body>
</html>

-- highlight.js ----------------------------------------------------------

/**
 * highlight.js – Highlights occurrences of text in HTML documents
 * @author (C) 2020  Thomas 'PointedEars' Lahn <js@PointedEars.de>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * The program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License at <http://www.gnu.org/licenses/>
 * for more details.
 */

var highlight = {
  getNeedle: function () {
    /* Get value of value of “find” parameter */
    var value = (window.location.search.match(/[?&]find=([^&#]+)/) || [,])
[1];
    if (value) value = decodeURIComponent(value);
    return value;
  },

  focus: function (needle) {
    if (needle)
    {
      /* Focus first occurence */
      if (typeof window.find != 'undefined' && !window.find(needle))
      {
        if (typeof console != 'undefined'
            && typeof console.log != 'undefined')
        {
          console.log('Text not found: "' + needle + '"');
        }
      }
    }
  },

  highlight: function (needle) {
    if (needle)
    {
      /* Highlight all occurrences */
      document.body.innerHTML = document.body.innerHTML.replace(
        new RegExp(
          /* slurp textareas and tags */
          '(<textarea>(?:[^<]|<[^\/])+<\/textarea>|<[^>]+>)|'
            + needle.replace(/[\]\\^$*+?.(){}|[]/g, "\\$&"),
          'gi'),
        function (match, tag, offset, all) {
          /* ignore elements/tags */
          if (tag) return tag;

          return ('<span style="background-color: yellow; color: black">'
            + match + '</span>');
        }
      );
    }
  },

  highlightAndFocus: function (needle) {
    if (!needle) needle = this.getNeedle();
    this.highlight(needle);
    this.focus(needle);
  }
};

--8<----------------------------------------------------------------------

F’up2 comp.lang.javascript

-- 
PointedEars
FAQ: <http://PointedEars.de/faq> | <http://PointedEars.de/es-matrix>
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.

[toc] | [prev] | [next] | [standalone]


#38678 — Re: Highlighting text (was: How get windows FIND() to work?)

From"Michael Haufe (TNO)" <tno@thenewobjective.com>
Date2020-08-05 21:59 -0700
SubjectRe: Highlighting text (was: How get windows FIND() to work?)
Message-ID<73508a05-413c-45ed-ad03-fce764f837beo@googlegroups.com>
In reply to#38660
On Wednesday, August 5, 2020 at 1:32:39 AM UTC-5, Thomas 'PointedEars' Lahn wrote:
> [...]
> 
>   highlight: function (needle) {
>     if (needle)
>     {
>       /* Highlight all occurrences */
>       document.body.innerHTML = document.body.innerHTML.replace(
> [...]

Wouldn't this heavy-handed approach break every event listener in the document that isn't inlined?

[toc] | [prev] | [next] | [standalone]


#38698 — Re: Highlighting text (was: How get windows FIND() to work?)

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2020-08-08 04:22 +0200
SubjectRe: Highlighting text (was: How get windows FIND() to work?)
Message-ID<1913226.oMNUckLgyt@PointedEars.de>
In reply to#38678
Michael Haufe (TNO) wrote:

> On Wednesday, August 5, 2020 at 1:32:39 AM UTC-5, Thomas 'PointedEars'
> Lahn wrote:
>> [...]
>> 
>>   highlight: function (needle) {
>>     if (needle)
>>     {
>>       /* Highlight all occurrences */
>>       document.body.innerHTML = document.body.innerHTML.replace(
>> [...]
> 
> Wouldn't this heavy-handed approach break every event listener in the
> document that isn't inlined?

Yes, it might.

-- 
PointedEars
FAQ: <http://PointedEars.de/faq> | <http://PointedEars.de/es-matrix>
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.

[toc] | [prev] | [next] | [standalone]


Page 2 of 3 — ← Prev page 1 [2] 3  Next page →

Back to top | Article view | comp.lang.javascript


csiph-web