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


Groups > alt.computer > #11872 > unrolled thread

How get windows FIND() to work?

Started byRobert Baer <robertbaer@localnet.com>
First post2020-08-03 19:13 -0700
Last post2020-08-05 08:32 +0200
Articles 12 on this page of 32 — 6 participants

Back to article view | Back to alt.computer


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? 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? 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

Page 2 of 2 — ← Prev page 1 [2]


#11886

FromArno Welzel <usenet@arnowelzel.de>
Date2020-08-05 07:56 +0200
Message-ID<hov01bFtpm8U2@mid.individual.net>
In reply to#11884
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]


#11896

FromRobert Baer <robertbaer@localnet.com>
Date2020-08-06 11:40 -0700
Message-ID<E8YWG.289677$DO2.76233@fx45.iad>
In reply to#11886
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]


#11905

FromArno Welzel <usenet@arnowelzel.de>
Date2020-08-07 14:26 +0200
Message-ID<hp4vjpF2lt6U1@mid.individual.net>
In reply to#11896
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]


#11888

From"R.Wieser" <address@not.available>
Date2020-08-05 08:59 +0200
Message-ID<rgdlds$mf7$1@gioia.aioe.org>
In reply to#11881
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]


#11893

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2020-08-06 01:11 +0200
Message-ID<XnsAC11C1D3833Ceejj99@194.109.6.166>
In reply to#11888
"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]


#11894

FromClifford Heath <no.spam@please.net>
Date2020-08-06 11:36 +1000
Message-ID<m8JWG.75479$355.6557@fx27.iad>
In reply to#11881
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]


#11895

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2020-08-06 12:24 +0200
Message-ID<XnsAC117E3999C56eejj99@194.109.6.166>
In reply to#11894
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]


#11901

FromRobert Baer <robertbaer@localnet.com>
Date2020-08-06 12:40 -0700
Message-ID<J0ZWG.289678$DO2.226369@fx45.iad>
In reply to#11895
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]


#11902

From"R.Wieser" <address@not.available>
Date2020-08-07 10:27 +0200
Message-ID<rgj3a8$1pvo$1@gioia.aioe.org>
In reply to#11901
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]


#11906

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2020-08-08 04:39 +0200
Message-ID<2553188.mvXUDI8C0e@PointedEars.de>
In reply to#11901
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]


#11903

FromClifford Heath <no.spam@please.net>
Date2020-08-07 18:46 +1000
Message-ID<3y8XG.111647$Vp4.22850@fx44.iad>
In reply to#11895
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]


#11887 — 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#11872
[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] | [standalone]


Page 2 of 2 — ← Prev page 1 [2]

Back to top | Article view | alt.computer


csiph-web